Re: [Cppcms-users] JSON integer conversion(s)
Brought to you by:
artyom-beilis
From: Hermann S. <of...@he...> - 2010-06-30 11:16:45
|
Using changeset 1298 together with Visual Studio 2008 creates the following test error: The following tests FAILED: 4 - json_test (Failed) Bye, Hermann > Hello, > > Thanks for the good point you bring. > > Actually not only integer number were not printed correctly, but floating point > ones as well. > I fixed this that numbers are printed with maximal possible precision and this > should solve problem > (I also added test case for such numbers) > > So your example generates 1277880000 string and not 1.27788e+09 > > (changeset 1298, you can take if from SVN) > > > >> I have noticed that the conversion of C++ integer numbers to json goes >> trough converting it to a double. This can get undesired behavior for >> large numbers when it automatic adds exponents when outputting it as >> json. > > Double is capable representing integer numbers correctly, so the problem is not > in converting > them to double but rather in printing them. > >> I want to keep the integer representation. If I want a double >> representation I will convert it myself explicitly. >> If possible by adding the function "void value::number(long int x);" >> this issue can be solved. >> > > This is not correct solution as neither JSON nor JavaScript have no integer or > double type they > have number type. So introducing "integer" type would be incorrect solution as > it extends JSON object > representation. > > IEEE floating point number can handle integer values correctly (with correct > rounding and precision) > so there no need to change internal representation. > > Also if you need real UUIDs neither integer nor double (and not even 64 bit > integer) would be good enough. > You should probably use string. > > > Thanks for the report, > Regards, > Artyom > > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > |