Number
#1

Код:
new Float:number;
number = -0.57;

if(number < 0)
{
    number = -number;
    printf("%d", number);
}
Why i have this 1058139013?

I search to transform -0.57 to 0.57
Reply
#2

PHP код:
if(number 0)
{
    
number = -number;
    
printf("%f"number);

PHP код:
 %integer 
PHP код:
 %float 
Reply
#3

oh yes i'm stupid looool
Reply
#4

Mistakes are made, glad I helped.
Reply
#5

When calculating float numbers, use
floatadd instead of +
floatsub instead of -
floatmul instead of *
floatdiv insrtead of /

More on Floats
Reply
#6

What? No reason for that. See "float.inc" in your pawno include folder - and look at all functions containing "operator" in name - those are operator overloads
Reply
#7

If you only need it once you can do, for example (removing the need of "number = -number;"):
PHP код:
printf("%f", -number); 
You could also do
PHP код:
number *= -1
instead of "number = -number;".
Reply
#8

Why are you trying to reinvent the wheel?

Код:
floatabs(Float: value);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)