MSVC: fix for failing tests due to strtod+hexadecimal literals

Kai Nacke via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Fri Mar 6 11:09:54 PST 2015


On Thursday, 5 March 2015 at 05:00:04 UTC, Dan Olson wrote:
> "Johan Engelen" <j at j.nl> writes:
>
>> On Tuesday, 3 March 2015 at 22:12:39 UTC, Dan Olson wrote:
>>>
>>> Could David Gay's strtod() be used?
>>> http://www.exploringbinary.com/how-strtod-works-and-sometimes-doesnt/
>>
>> Thanks for that link. I had a look at David Gay's strtod() (a
>> complicated piece of code) and it also accepts hex floats [1].
>> I think it is clear that my hex parser is much simpler but also
>> more naive and may need quite some extra complication to make 
>> it
>> deal with all corner cases (I am by no measure an expert on 
>> IEEE
>> fp). Although a fun exercise, I guess I should accept the fact
>> that David Gay's function is very much superior to mine :)
>>
>> Should we replace MSVC's strtod() altogether with David Gay's, 
>> or
>> use only the hex parser "gethex()"?
>
> Personally I don't know but it does look like the gethex() 
> function
> could be used.  I would think whatever is easiest to keep going 
> and
> passes unittests.  BTW, David Gay is listed as the author in 
> BDS man
> page for strtod (uses by OS X).
>
> Another thing.  Kai has worked on using LLVM'S own float 
> (APFloat)
> support class.  Seem to me like this will eventually be the 
> best way to
> go as it does all this and will be consistent across platforms.
>  Clang
> appears to use this to parse float literals (I just grepped the 
> source).
>
> P.S. exploringbinary is a fun website.

Hi Dan!

Thanks for the hint! I now use the LLVM functions instead of MSVC 
strtold(). Maybe someone can comment on the test results?

Regards,
Kai


More information about the digitalmars-d-ldc mailing list