Rate - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Rate (
/showthread.php?tid=599237)
Rate -
Sensation - 23.01.2016
printf("%f",3 / 2); is printing 0.00000 why? Please help me..
Re: Rate -
Vince - 23.01.2016
Integer divided by integer remains integer. It doesn't magically change type. For integer divisions, any fractional part in the outcome is discarded and no rounding is performed.
Re: Rate -
Sensation - 23.01.2016
Quote:
Originally Posted by Vince
Integer divided by integer remains integer. It doesn't magically change type. For integer divisions, any fractional part in the outcome is discarded and no rounding is performed.
|
So what can i do?
Re: Rate -
IstuntmanI - 23.01.2016
printf("%f",Float:3 / Float:2);
or
printf("%f",3.0 / 2.0);
Re: Rate -
AbyssMorgan - 23.01.2016
One argument must be characteristic of the float
PHP код:
printf("%f",3 / 2.0); //1.5
printf("%f",3.0 / 2); //1.5