floatround problem
#1

When i try this:

PHP код:
new 500;
new 
10;
new 
floatroundb/100*);
printf("Result: %d"c); 
I get 'c' = 0, but the correct answer is 50. Wtf? Why?
Reply
#2

pawn Код:
floatround(c, floatround_ceil);
Reply
#3

PHP код:
new 498;
new 
7;
new 
Float:b/100*a// it's 34,86
new floatround); // it's 35
printf("Result: %d"c); 


What's wrong?
Reply
#4

The right part gets executed first and then the result is written to the part on the left. Define your operands as a float with the appropriate tag, or use float(), or use any of the float functions (floatmul, floatdiv). It might also simply work like this, although I'm not entirely sure;
pawn Код:
new Float:d = b/100.0*a;
The '.0' is important. Actually that should be done at all times when working with floating point values in Pawn. Even in functions like SetPlayerHealth, etc.
Reply
#5

But really in pawn not observed mathematical action order?
Anyway thanks, i try this 'b/100.0*a' and it works.
Reply
#6

I didnt't ignore your post, i just didn't consider it helpful, because given expression IS a float, but you wrote that it isn't..
Reply
#7

Код:
new Float:a = 500.0; 
new Float:b = 10.0; 
new Float:d=b/100*a
new c = floatround(d,  floatround_ceil); 
printf("Result: %d", c);
Reply
#8

******, i respect you and your jobs, but really, this answer wasn't enough informative for me. "Neither of your inputs are floats", and what? Why they arent'a floats? What should i do with this? Your knowledge is your knowledge and i can't read your mind, so i asked this topic question
Reply
#9

Rittik, thank you, i already understood
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)