Monte Goulding's day off? ;-) mergJSON - Documented Bug or Feature?

Lagi Pittas iphonelagi at gmail.com
Wed Jun 29 07:22:03 EDT 2016


Hi,

I used the mergJSON in version 8 DP1 today for the first time.
I loaded my CSV file into the program and build my arrays then exported the
array as JSON.

what do I find?

prices that were 1.40 showing up as 1.3999999999999999,  2.30 showing as
2.2999999999999998 etc

Now I know this is documented as anything that looks like a real number is
stored as an IEEE 754 double.


Can someone please explain the logic that says that a textual
representation of information (CSV, XML a text file even) is translated to
a IEEE number for us to round as we see fit?

Please explain any cases where this makes any sense at all.

if I wanted the number to be 1.399999 thats what I would put in there.

Now the documentation says round it to the precision you want - it already
is otherwise it wouldn't be in the CSV/JSON file if it was wrong in the
first place.

Anyone got any thoughts on this?

Monte as much as I respect your programming prowess I respectfully think
you are wrong on this one - it has to be more coding to do it this way than
to leave it as text - or am I missing something.

Shouldn't there be a parameter that asks if we want this (with false as the
default?) as per the pretty print which works brilliantly by the way -
perfect in fact.

I wrote a JSON library for Visual foxpro a couple of years ago and the only
change it made was if there was an integer of say 1 or 2 it would change it
to 1.0 or 2.0 because Foxpro itself reads any numbers from a file as Real
rather than integer but the actual value is still the same 1.0 is 1. I
could have coded against that but it would have been a bit convoluted and
would have slowed the system down so I left it as is.

KIndest Regards Lagi



More information about the use-livecode mailing list