Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javascript script float fields not comparable (works in x-ite) #89

Closed
splace opened this issue Apr 17, 2019 · 4 comments
Closed

javascript script float fields not comparable (works in x-ite) #89

splace opened this issue Apr 17, 2019 · 4 comments

Comments

@splace
Copy link

splace commented Apr 17, 2019

#VRML V2.0 utf8 Titania V4.5.0

Script {
	field SFFloat f 0.001
	  url "javascript:
		  function initialize(){
			 Browser.println(f==0.001) 
	    }  
	  "
	}
}

// output: false
@create3000
Copy link
Owner

This is because you define f as SFFloat which is internally really a float with a precision of 6-7 digits but JavaScript uses alway double precision numbers. If you access f in JavaScript the float value is converted to double which result in a number like 0.0010000000474974513 which is not 0.01 double.

@create3000
Copy link
Owner

Use SFDouble values if you need to compare the values.

@splace
Copy link
Author

splace commented Apr 17, 2019

Use SFDouble values if you need to compare the values.

this is from a broken world i found, not from me (as are virtually all my reports) their whole usefulness is to show when the browser is not behaving as older browsers did.

@splace
Copy link
Author

splace commented Apr 17, 2019

the standard requires this to work; because it specifies ISO/IEC 19775 ECMAScript, which is without typing, what seems to be happening is that you have used a more modern version of js (with typing) in a non backwardly-compatible manor.

@splace splace changed the title javascript script float fields not comparable javascript script float fields not comparable (works in x-ite) Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants