Posts: 18
Threads: 8
Joined: Nov 2008
Reputation:
0
Hello.
I need to make one script but i stoped to div.
For example I have two numbers 11 and 2. I want to div it. (11/2)
simple new num=11/2 i get just 5
new float:num=11/2 i get 55
but how to get 5.5?
Posts: 4,885
Threads: 57
Joined: Jun 2012
Reputation:
0
Your dividing integers but your result would be a float so you need to do some conversions.
the float() function takes an integer and converts it to a float.
The solution is quite simple.
new Float:result;
result = floatdiv(float(11), float(5));
Posts: 18
Threads: 8
Joined: Nov 2008
Reputation:
0
new Float:Number1 = 100, Float:Number2 = 95;
new Float:test;
test = floatdiv(Number1, Number2);
format(msg,sizeof(msg),"I get: %i",test);
SendClientMessage(playerid,RED,msg);
I made it but test now is: 1065794722. And I dont get it why
Posts: 4,885
Threads: 57
Joined: Jun 2012
Reputation:
0
format(msg,sizeof(msg),"I get: %i",test);
gotta use the Float specifier
format(msg,sizeof(msg),"I get: %f",test);