Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

-10.920407 / (24 / 90) = Math Error

Huns Valen
Don't PM me here.
Join date: 3 May 2003
Posts: 2,749
11-05-2004 18:52
Make a cube and put this script into it:

CODE
default {
state_entry() {
llSay(0, (string)(-10.920407 / (24 / 90)));
}
}


Object: Script run-time error
Object: Math Error

According to my TI-83, the answer is -40.95752625...
Moleculor Satyr
Fireflies!
Join date: 5 Jan 2004
Posts: 2,650
11-05-2004 19:05
Maybe this is why XyCalc hasn't worked since 1.5's release.
_____________________
</sarcasm>
Carnildo Greenacre
Flight Engineer
Join date: 15 Nov 2003
Posts: 1,044
11-05-2004 23:04
According to my computer, the answer is -NaN:

(24 / 90) = 0
-10.920407 / 0 = -NaN
_____________________
perl -le '$_ = 1; (1 x $_) !~ /^(11+)\1+$/ && print while $_++;'
Huns Valen
Don't PM me here.
Join date: 3 May 2003
Posts: 2,749
11-05-2004 23:19
From: Carnildo Greenacre
(24 / 90) = 0
and you thought creative mathematics was the sole domain of Enron executives!

maybe it needs to be 24.0/90.0 so that the compiler knows it is looking at floats and not integers.
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
11-06-2004 11:58
You can get into trouble when mixing floats and integers. LSL doesn't deal with implicit typecasting very well. To be safe, always stick to one format.

Remember, 24 / 90 == 0.
24.0 / 90.0 == 0.266667.
Integers are whole numbers. If you want decimal places, you have to use floats.

The math error is the result of dividing 24 by 90, getting 0, then attempting to divide -10.920407 by 0. You can't do that. :)
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
11-06-2004 14:10
ehhh once you get use to the weirdness of integer math, you can exploit it. But you never become happy with it.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey