h3x4n1um / RETON

Reverse Engineering RTON File
GNU General Public License v3.0
32 stars 3 forks source link

Problem about float type #7

Closed LambdaEd1th closed 4 years ago

LambdaEd1th commented 4 years ago

'Infinity', '-Infinity' and 'NaN' are existed in the float and double type. PositiveInfinity NegativeInfinity

When converting these values, the tool will convert them into null without distinction. Here is the sample file. PlantLevels.zip

h3x4n1um commented 4 years ago

Thankyou for pointing out, I'm gonna look into this special case

h3x4n1um commented 4 years ago

This problem can be fixed by using std::numeric_limits std::isnan and std::isinf

My problem is when converting json2rton, if it reads a Infinity, -Infinity or NaN, should it processes as string or floating-point type? And if it processes as floating-point what if someone writes in json like this:

{"Infinity": "NaN"}
nineteendo commented 3 years ago

If someone writes "Infinity": "NaN" in json this should definitely be treated as a string, no need to detect that.

Thanks for pointing this out, luckily in python with the json library allow_nan is set to True by default, so this doesn't cause issues in my python alternative to RETON.