Math and Floats [Solved]

Started by KamikazeHighland, Mon 13/06/2011 01:29:24

Previous topic - Next topic

KamikazeHighland

float Value = int1 * (3/4);  returns cannot convert 'int' to 'float'.

float int1float = IntToFloat(int1);
float Value = int1float * (3/4); returns cannot convert 'float' to 'int'.

float float1 = 1
float Value = float1 * (3/4); returns cannot convert 'float' to 'int'.

Using (.75) returns Parse error in expr near "."

All I want is for a number with a decimal.  What am I doing wrong?

ddq

Use the functions IntToFloat and FloatToInt. Details are in the manual. And as far as .75 giving a parse error, you have to have the zero in front (0.75). Same with putting .0 to do float math like 3.0/4.0.

Code: ags

float Value = IntToFloat(int1) * (3.0 / 4.0); 
// or
float Value = IntToFloat(int1) * 0.75; 

Gilbert

Change (3/4) to (3.0/4.0) or 0.75 . I'm not sure, but it's possible that .75 won't work. You need to use 0.75.


SMF spam blocked by CleanTalk