View Issue Details

IDProjectCategoryView StatusLast Update
0008853Multi Theft Auto : San AndreasScriptingpublic2015-07-26 01:48
ReporterGallardo9944 Assigned Toccw  
Status resolvedResolutionfixed 
Product Version1.4 
Target Version1.5Fixed in Version1.5 
Summary0008853: toJSON passes wrong floats

toJSON converts "normal" floats to long and wrong ones

Steps To Reproduce

/run outputChatBox(toJSON({5.1}))
[ [ 5.0999999046325684 ] ]

Additional Information

Detected after reporting

TagsNo tags attached.



2015-05-16 23:09

administrator   ~~0023280

That's how IEEE floating point numbers work. The best representation for 5.1 is 5.099999904632568.


2015-05-27 09:51

administrator   ~~0023320

Would be nice to do something about this.
I noticed we are float casting when going to/from json, so keeping the double would help.
I also found this:
It seems the json developers have been fiddling with the double to string conversion. They say that %.17g is best because numbers like 12.300000000000001 won't get rounded to 12.3
If we disagree and think 12.3 is better, then we'll have to change the json source to use %.16g or less.


2015-07-25 22:49

viewer   ~~0023719

Seems like it's fixed in 1.5.

ER+#666666iGOR executed command: outputChatBox(toJSON({5.1}))
[ [ 5.1 ] ]

ER+#666666iGOR executed command: outputChatBox(toJSON(123.321))
[ 123.321 ]

Issue History

Date Modified Username Field Change