#1 2021-10-26 11:38:24

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 218
Website

Delphi 11 - Float to JSON broken

Hi Arnaud,

I believe, that this is a compiler problem, but want to check with you first.

Paste: https://pastebin.com/dzhFBtLv

When running with Delphi 10.4, I get the expected result:

{"Float":0.434797083333224}

When running with Delphi 11, I get invalid JSON:

{"Float":0.4347970833332◄0}

"◄" is Char #11

When changing the method DoubleToJson in mormot.core.text, so that FloatToJsonNan is not called, and simple set

Result := @tmp;

the result is as expected.

Regards,
Daniel

P.S.: It happens only with values, that have larger precision.

Last edited by sakura (2021-10-26 11:39:01)

Offline

#2 2021-10-26 16:57:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: Delphi 11 - Float to JSON broken

What do you call "larger precision"?

Do you mean Extended on Win32?
Is it OK with Double values?

Offline

#3 2021-10-26 20:17:09

sakura
Member
From: Germany
Registered: 2018-02-21
Posts: 218
Website

Re: Delphi 11 - Float to JSON broken

I mean, when you define enough digits. Like the one in the sample, 0.434797083333224 - that is precise enough to create the problem, however, 0.43479708 will work just fine.

Offline

Board footer

Powered by FluxBB