[HELP]Number in variable with comma
#1

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?
Reply
#2

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));
Reply
#3

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

format(msg,sizeof(msg),"I get: %i",test);

gotta use the Float specifier

format(msg,sizeof(msg),"I get: %f",test);
Reply
#5

Nice, Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)