Subtracting decimals

Posted by Sirius096 on Wed 08 Feb 2006 01:03 AM — 3 posts, 15,087 views.

#0
Hi there.
I wrote a function to take a certain number away from 100 and then divide by another number, eg:

(100-4.598)/.0125

Now my problem is, MC (or jscript?) can't seem to handle taking a decimal off 100, it just rounds the decimal up and produces a whole number. I have the value I'm taking off 100 stored as a variable and my function is written as such;

function GXPCounter(g2n)
{
var g2n = world.GetVariable("g2n");
world.SetVariable("g2n2", parseInt(100-(world.GetVariable("g2n"))));
world.Note("Rounds for FM: " + parseInt((world.GetVariable("g2n2"))/.0125));
}

Can someone tell me what I'm doing wrong?
Cheers
-Siri
USA #1
parseInt is probably your problem. Integers don't have decimal points. Try parseDouble or parseFloat -- but I'm not sure what the exact function is.
#2
Woot!
parseFloat worked a charm!
Thanks alot. :)