[FFmpeg-devel] [PATCH] eval: implement av_strtod internally.

Nicolas George nicolas.george at normalesup.org
Tue Feb 28 16:37:25 CET 2012


Le nonidi 9 ventôse, an CCXX, Alexander Strasser a écrit :
>   Your implementation might also be less precise than most standard C library
> implementations. The attached program should reveal few of those occurrences.
> 
>   You might want to dig into Rick Regan's blog if you don't have already.
> He should have accumulated plenty of information that is useful to consider
> when doing a project similar to your patch. 
> 
>   I believe this explains the problem I have mentioned above:
>   http://www.exploringbinary.com/quick-and-dirty-decimal-to-floating-point-conversion/

Thanks for the pointer. My implementation is good for 0.9199 and 1.89, since
it does not treat the decimal part separately but rather add the position of
the decimal point to the exponent.

It fails on 18014398509481993 and 3.50582559e-71.

I can make 18014398509481993 work either by making mantissa a long double,
which is probably a little bit cheating, or an uint64_t, which requires a
little bit more work but not much.

As for 3.50582559e-71, I can make it work by using "mantissa * pow(10, exp)"
rather than a binary integer exponentiation, but I do not like that solution
very much.

I will think about it some more while I work on the rest of my proposal.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120228/a5cd28ce/attachment.asc>


More information about the ffmpeg-devel mailing list