Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Weird behaviour on encoding fractional numbers

A topic by maciek012 created Apr 07, 2018 Views: 368 Replies: 1
Viewing posts 1 to 2

Hi I have noticed that when key's value is double digit and has a fraction of 2, 

for example { "key": 13.2 } TJSON will output "key":  13.199999999999999

Developer

TJSON uses string_format(number, 0, 15) and then trims trailing zeroes to maintain original precision in case it matters.

Default string() function will round the number to two-digit precision.

Default number comparison operators use threshold as per math_set_epsilon.

In other words, the numbers are often stored with strange fractions, but the fact can be slightly obscured.