[fixed]A problem with fast_atof and serialization

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
CuteAlien
Admin
Posts: 9735
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

[fixed]A problem with fast_atof and serialization

Post by CuteAlien »

I found a problem when I tried to find out why my SpinBox no longer worked. In short the problem turned out to be that for FLT_MAX and -FLT_MAX the serialization failed because fast_atof seems to have different borders.

For:

Code: Select all

f32 test = core::fast_atof("340282346638528859811704183484516925440.000000");
f32 test2 = core::fast_atof("-340282346638528859811704183484516925440.000000");	
test is 0 and test 2 is -0 (while it's +/- FLT_MAX for atof).

That's maybe OK in other situations, but at least for the serialization it shouldn't be used. I have replaced it now by atof in a few places until it worked for me. That was both occurrences in CXMLReaderImpl.h and the setString in CFloatAttribute in CAttributeImpl.h. I suppose the latter one was responsible for the problems in my case as it worked afterwards. But maybe the other uses should also be changed.

Even better would certainly be a change to fast_atof which works with those numbers, but I have to pass on that fun exercise :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Thanks for the report. This should be fixed in SVN 1647.

See bug 1865300 for a test app.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
CuteAlien
Admin
Posts: 9735
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Thanks for fixing. But it leads to some compile-problem right now on linux:

MeshFileLoader.o CBSPMeshFileLoader.cpp
In file included from ../../include/IQ3Shader.h:9,
from ../../include/IQ3LevelMesh.h:9,
from CQ3LevelMesh.h:8,
from CBSPMeshFileLoader.cpp:9:
../../include/fast_atof.h: In function 'irr::s32 irr::core::strtol10(const char*, const char**)':
../../include/fast_atof.h:66: error: 'INT_MAX' was not declared in this scope
../../include/fast_atof.h: In function 'irr::f32 irr::core::strtof10(const char*, const char**)':
../../include/fast_atof.h:92: error: 'UINT_MAX' was not declared in this scope

edit: On linux you need to include limits.h instead of float.h. Maybe that even works also on Windows (can't test right now).

edit2: Beside that the fix does it's job :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Oops, sorry about that. windows.h includes limits.h, although I can't immediately see how that's getting included before fast_atof.h

I've added <limits.h> in fast_atof.h in SVN 1648, although conceivably it (and float.h) could go in irrMath.h instead.

Also, while I'm going to score myself a Linux install for my precommit tests, I will continue to shower daily. :)
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
CuteAlien
Admin
Posts: 9735
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

rogerborg wrote: Also, while I'm going to score myself a Linux install for my precommit tests, I will continue to shower daily. :)
It's generally acceptable to stop cutting your hair instead ;-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply