Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Help with CopperCube
Strange bug about if statement

Alireza
Guest
Quote
2021-11-30 15:01:19

I made a cubeMesh. And then I set it's X Rotation to 0.1

After getting its rotation variable, I used this code:

If ( rot .x == 0.1 ) {
....do some thing ....
}

And I tested it. It worked well on Windows but did not work on Android.

Then I used this code instead and it worked !!! on Android:

If ( rot .x > 0.09 && rot .x < 0.11 ) {
....do some thing ....
}

It should be noted that in larger values, for example, if I had initially X rotation = 1, it would work fine.

.It's so weird. Whatever I thought, I could not find a logical reason for it


erik
Registered User
Quote
2021-12-01 15:02:46

That's not a bug, that's how floating point work. You figured out yourself how to fix this. The usual way is to test for a small value below and above the value you want.


Alireza
Guest
Quote
2021-12-01 16:15:58

Thankful. So why did it (== ) work in Windows ?


adteam43
Registered User
Quote
2021-12-16 02:14:07

Alireza, you must understand the Android Code its not the same with the Javascript.

Integer or floating operators its not working in Android cellphones or iOS.

Check the code again, something its missing for the Android implementation code or play around with the values to fit in what you need.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "?nternational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact