Float rounding (in JSON)

bauss jacobbauss at gmail.com
Fri Oct 14 09:43:00 UTC 2022


On Friday, 14 October 2022 at 09:00:11 UTC, Patrick Schluter 
wrote:
> On Thursday, 13 October 2022 at 19:27:22 UTC, Steven 
> Schveighoffer wrote:
>> On 10/13/22 3:00 PM, Sergey wrote:
>>> [...]
>>
>> It doesn't look really that far off. You can't expect floating 
>> point parsing to be exact, as floating point does not 
>> perfectly represent decimal numbers, especially when you get 
>> down to the least significant bits.
>>
>> [...]
> To me it looks like there is a conversion to `real` (80 bit 
> floats) somewhere in the D code and that the other languages 
> stay in `double` mode everywhere. Maybe forcing `double` by 
> disabling x87 on the D side would yield the same results as the 
> other languages?

Looking through the source code then for floating points we call 
`parse!double` when parsing the json as a floating point.

I don't see real being used anywhere when parsing.

So if anything then it would have to be internally in parse or 
dmd. I haven't checked either yet.


More information about the Digitalmars-d-learn mailing list