[SOLVED]Maths problem?
#1

Код:
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?
Reply
#2

Use %f instaid of %i
Reply
#3

No luck. Now it just comes up with like 0.00000 instead.
Reply
#4

Try saving it into a variable before using it in the function. I guess that is the prob.
Reply
#5

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
Reply
#6

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...
Reply
#7

Heh. Thank you very much for your help DeathOnaSnake
Reply
#8

Quote:
Originally Posted by Celson
Heh. Thank you very much for your help DeathOnaSnake
DeathOnaStick, but never mind .
No prob
Reply
#9

Quote:
Originally Posted by DeathOnaStick
Quote:
Originally Posted by Celson
Heh. Thank you very much for your help DeathOnaSnake
DeathOnaStick, but never mind .
No prob
Yikes. Lol sorry about that DeathOnaStick.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)