Thyme math issues

If you have problems installing or running Algodoo, have found a bug or need in-game help - this is it!

Thyme math issues

Postby Ivan » Mon Sep 17, 2012 6:12 pm

1. Division of a float with zero returns +inf.
2. math.toInt(+inf) and math.toInt(NaN) return -2147483648.

Examples:
Code: Select all
> 0.0 / 0
+inf

> 1.0 / 0
+inf

> math.toInt(+inf)
-2147483648

> math.toInt(NaN)
-2147483648
User avatar
Ivan
 
Posts: 203
Joined: Tue Oct 06, 2009 2:01 pm
Location: Croatia

Re: Thyme math issues

Postby Kilinich » Mon Sep 17, 2012 10:27 pm

and? is it a problem?
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Thyme math issues

Postby electronicboy » Tue Sep 18, 2012 12:16 am

The problem with this is that there is 2 options; diving by 0 can either return 0 or +inf.
although you are taught in school that when you divide be 0, you get 0, when actually, you can put millions upon billions of 0 into any number, this +inf is technically correct, while 0 is more of a standard in school teaching.
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm

Re: Thyme math issues

Postby Kilinich » Tue Sep 18, 2012 6:59 am

ohh, common, just add <>0 check in your code.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Thyme math issues

Postby Ivan » Tue Sep 18, 2012 2:42 pm

To electronicboy:
Thanks for your reply! I am aware of that. The problem was more with math.toInt(+inf) and 0.0/0 which should give NaN (or 0 to keep is simple) because 0 : x = 0, x : x = 1 and x : 0 = ±inf.

To Kilinich:
The code would look neater if there was no need for <>0 check.
User avatar
Ivan
 
Posts: 203
Joined: Tue Oct 06, 2009 2:01 pm
Location: Croatia

Re: Thyme math issues

Postby Conundrumer » Thu Sep 20, 2012 11:11 pm

The value of +inf or NaN in hex is 0x80000000, when converted to signed int, literally translates to the most negative number. Ints don't have +inf or NaN, so unless you want the program to crash or throw an exception, that's the only option you have. Of course, you can do the <>0 check instead. Algodoo wasn't designed to handle poor scripting.
User avatar
Conundrumer
 
Posts: 344
Joined: Mon Aug 31, 2009 5:55 pm
Location: NYC

Re: Thyme math issues

Postby Ivan » Fri Sep 21, 2012 3:23 pm

Thanks for clarifying me some things, Conundrummer.
User avatar
Ivan
 
Posts: 203
Joined: Tue Oct 06, 2009 2:01 pm
Location: Croatia


Return to Help / Bug reports

Who is online

Users browsing this forum: No registered users and 7 guests