[x3d-public] X3DJSAIL. Java numbers differ from XML intermediate output. There is a problem with trailing 0's algorithm I think.

Don Brutzman brutzman at nps.edu
Sat Mar 11 14:26:28 PST 2017


On 3/11/2017 8:00 AM, yottzumm at gmail.com wrote:
> I think there may be a problem in the trailing 0 digit processor.  Perhaps take it out.   See attached two files and JSON diff for details.  Perhaps it is not a smart idea to take unchecked Stack Overflow answers.

===================================================
@2 /X3D/head/meta/8/@content/0/0 /X3D/head/meta/8/@content/0/0
< 10
> 11
@8 /X3D/Scene/-children/0/Group/-children/0/PointLight/@location/0 /X3D/Scene/-children/0/Group/-children/0/PointLight/@location/0
< 10000000000
> 10
@8 /X3D/Scene/-children/0/Group/-children/1/PointLight/@location/0 /X3D/Scene/-children/0/Group/-children/1/PointLight/@location/0
< -10000000000
> -10
@8 /X3D/Scene/-children/0/Group/-children/2/PointLight/@location/1 /X3D/Scene/-children/0/Group/-children/2/PointLight/@location/1
< 10000000000
> 10
@8 /X3D/Scene/-children/0/Group/-children/3/PointLight/@location/1 /X3D/Scene/-children/0/Group/-children/3/PointLight/@location/1
< -10000000000
> -10
@8 /X3D/Scene/-children/0/Group/-children/4/PointLight/@location/2 /X3D/Scene/-children/0/Group/-children/4/PointLight/@location/2
< 10000000000
> 10
@8 /X3D/Scene/-children/0/Group/-children/5/PointLight/@location/2 /X3D/Scene/-children/0/Group/-children/5/PointLight/@location/2
< -10000000000
> -10
Different
===================================================

Another good catch by unit testing with X3D Example Archives.

The problem has been fixed by only stripping zeroes if a decimal point appears in the String version of the value.  This issue didn't occur in the examples I tested, really large double values like these were missing the ".0" which occurred in other tests.

As far as Stack Overflow goes, it is pretty excellent and you get a confidence level from the comments that are included.  Nothing is completely perfect, testing helps.

btw found another reference online, ORA Regular Expressions Cookbook includes online reference.

https://library.oreilly.com/book/0636920023630/regular-expressions-cookbook-2nd-edition/toc

Not needed in this code, but perhaps in the future in other tools:
6.6. Strip Leading Zeros
https://library.oreilly.com/book/0636920023630/regular-expressions-cookbook-2nd-edition/275.xhtml

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the x3d-public mailing list