[SOLVED]Maths problem? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED]Maths problem? (
/showthread.php?tid=115320)
[SOLVED]Maths problem? -
Celson - 23.12.2009
Код:
new u[128];
format(u,sizeof(u),"%i",(1/2)*100);
SendClientMessage(playerid,RED,u);
My calculator says that should equal to 50. For some strange reason... it comes up as 0
Anybody know why?
Re: Maths problem? -
FUNExtreme - 23.12.2009
Use %f instaid of %i
Re: Maths problem? -
Celson - 23.12.2009
No luck. Now it just comes up with like 0.00000 instead.
Re: Maths problem? -
DeathOnaStick - 23.12.2009
Try saving it into a variable before using it in the function. I guess that is the prob.
Re: Maths problem? -
Celson - 23.12.2009
Quote:
Originally Posted by DeathOnaStick
Try saving it into a variable before using it in the function. I guess that is the prob.
|
Yeah I also tried that. No luck
Re: Maths problem? -
DeathOnaStick - 23.12.2009
Quote:
Originally Posted by Celson
Quote:
Originally Posted by DeathOnaStick
Try saving it into a variable before using it in the function. I guess that is the prob.
|
Yeah I also tried that. No luck
|
Oww i see... i know the sollution:
1/2 = 0.5 . That's a float.
The script looks at it as a integer so it cuts off the ".5"... what stays?
0 !
0*100... sure that's
0, too.
Sollution:
pawn Код:
new u[128];
format(u,sizeof(u),"%f", floatmul(floatdiv(1.0, 2.0), 100.0));
SendClientMessage(playerid,RED,u);
Cheers
#Edit#: I changed %i to %f...
Re: [SOLVED]Maths problem? -
Celson - 23.12.2009
Heh. Thank you very much for your help DeathOnaSnake
Re: [SOLVED]Maths problem? -
DeathOnaStick - 23.12.2009
Quote:
Originally Posted by Celson
Heh. Thank you very much for your help DeathOnaSnake
|
DeathOna
Stick, but never mind
.
No prob
Re: [SOLVED]Maths problem? -
Celson - 23.12.2009
Quote:
Originally Posted by DeathOnaStick
Quote:
Originally Posted by Celson
Heh. Thank you very much for your help DeathOnaSnake
|
DeathOna Stick, but never mind .
No prob
|
Yikes. Lol sorry about that DeathOnaStick.