wtf now? division is always rounded?
4 posts • Page 1 of 1
wtf now? division is always rounded?
got this code:
ok look at the phase variable...
now have a look at the attached pic:
so (149-120)/(200-120) = 0.0 ?????
there are no error message, i checked divisor and dividend, both are okay.. so WHAT THE HECK ?
edit: when divisor = divident, it's 1 ..
- Code: Select all
(e)=>{
Scene.my.timer = Scene.my.timer + 1; scene.my.current_0 = scene.my.robotMoves_0((scene.my.step_0 * 2) + 2); scene.my.next_0 = scene.my.robotMoves_0((scene.my.step_0 + 1) * 2 + 2); scene.my.current_0_t = scene.my.robotMoves_0((scene.my.step_0 * 2) + 1); scene.my.next_0_t = scene.my.robotMoves_0((scene.my.step_0 + 1) * 2 + 1); Scene.my.step_0 < (Scene.my.robotMoves_0(0) - 1) ? { Scene.my.phase = ((scene.my.timer - scene.my.current_0_t) / (scene.my.next_0_t - scene.my.current_0_t)); Scene.my.angle_0_target = ((1.0 - (Scene.my.phase * scene.my.current_0)) + (Scene.my.phase * scene.my.next_0)) * ( - math.pi); Scene.my.timer > scene.my.robotMoves_0(((scene.my.step_0 + 1) * 2) + 1) ? {Scene.my.step_0 = Scene.my.step_0 + 1} : {} } : {} }
ok look at the phase variable...
now have a look at the attached pic:
so (149-120)/(200-120) = 0.0 ?????
there are no error message, i checked divisor and dividend, both are okay.. so WHAT THE HECK ?
edit: when divisor = divident, it's 1 ..
- Attachments
-
algobug.jpg- (87.28 KiB) Not downloaded yet

- pixartist
- Posts: 65
- Joined: Wed Sep 02, 2009 5:30 pm
Re: wtf now? division is always rounded?
You're dividing integer values. It sounds crazy but your solution was calculated correctly because your solution will also be an integer value.
If you want algodoo to let it calculate decimal places you first have to make the fraction a float value.
It's easy: just put ".0" at the end of one value. The thyme function for that is math.tofloat()
For example:
If you want algodoo to let it calculate decimal places you first have to make the fraction a float value.
It's easy: just put ".0" at the end of one value. The thyme function for that is math.tofloat()
For example:
- Code: Select all
(149.0-120)/(200-120) = 0.3625
Last edited by KarateBrot on Wed Jan 20, 2010 3:22 pm, edited 1 time in total.

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: wtf now? division is always rounded?
not a bug.
1 is integer: 1 * 2.2 = 2
1.0 is float: 1.0 * 2.2 = 2.2
1 is integer: 1 * 2.2 = 2
1.0 is float: 1.0 * 2.2 = 2.2
Dream of Algodoo as game development engine...
-

Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: wtf now? division is always rounded?
Kilinich wrote:not a bug.
1 is integer: 1 * 2.2 = 2
1.0 is float: 1.0 * 2.2 = 2.2
But the solution for 1*2.2 will also be 2.2. There just needs to be one float value and the solution will get converted to float.

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
4 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests



