Float won't floatmath doesn't add up

Post » Sat Jan 05, 2013 11:58 am

I am having a bit of an issue trying to use a float variable to keep track of a ratio between other factors. The variable is essentially behaving like a short- if it 'should' be 1 it is 1, but if it should be anything in between 0 and 1 it is set to 0. The exact formula is as follows:

set float1 to ( ( short1 - short2 ) / short1 )

For testing purposes, I added a message box to the following line that displays the values of the relevant variables (both shorts are behaving as expected, so I know that's not the problem). When short2 is 0, float1 is set to 1, as it should be. However, when short2 is any value than 0 (but still less than short1) float1 is set to 0.

I'm not sure whether there's something causing the float not to save decimal values, or whether the division isn't working as it should, or if I am just missing something really obvious because I have been working on this script for so long. At any rate, I would appreciate any insight that anyone might have. And to address the two most obvious oversights; I am completely sure that I did define it as a float at the beginning of the script, and the message box displays float1 in it's entirety (0.00000...), so I know it's not just rounding for the display.
User avatar
Lifee Mccaslin
 
Posts: 3369
Joined: Fri Jun 01, 2007 1:03 am

Return to III - Morrowind