Float? No idea. - 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: Float? No idea. (
/showthread.php?tid=310338)
Float? No idea. -
Ubuntu - 11.01.2012
I had a problem with floats.
static Float:testnumber = 3.01;
printf("%f", testnumber);
Results:
3.00.
Do you have any idea why I'm having 3.00 instead of 3.01?
Thanks.
Re: Float? No idea. -
Psymetrix - 11.01.2012
Try not using static.
AW: Float? No idea. -
Ubuntu - 11.01.2012
new Float:number = 0.01;
printf("%.2f", number);
Results: 0.00
new Float:number = 0.01;
printf("%.3f", number);
Results: 0.009
Re: Float? No idea. -
Gh05t_ - 11.01.2012
Quote:
Originally Posted by Psymetrix
Try not using static.
|
Why?
AW: Float? No idea. -
Ubuntu - 11.01.2012
Anyone have an idea why it doesn't give the right float?
Re: Float? No idea. -
Psymetrix - 11.01.2012
Quote:
Originally Posted by Gh05t_
Why?
|
It was just a suggestion. Are floats accurate in PAWN?
AW: Float? No idea. -
Ubuntu - 11.01.2012
I don't think so, otherwise it would be 0.01 instead of 0.009.
AW: Float? No idea. -
Ubuntu - 11.01.2012
Sorry for double post, I found the problem.
If you want 0.01 then you can just add 0.001 to 0.009 which equals 0.01