Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: KamikazeHighland on Mon 13/06/2011 01:29:24

Title: Math and Floats [Solved]
Post by: KamikazeHighland on Mon 13/06/2011 01:29:24
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?
Title: Re: Math and Floats
Post by: ddq on Mon 13/06/2011 02:10:09
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.


float Value = IntToFloat(int1) * (3.0 / 4.0);
// or
float Value = IntToFloat(int1) * 0.75;
Title: Re: Math and Floats
Post by: Gilbert on Mon 13/06/2011 02:10:29
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.
Title: Re: Math and Floats [Solved]
Post by: KamikazeHighland on Mon 13/06/2011 02:29:02
Thanks!  8)