Question In Regards To 'floatcmp' Usage?
#1

Would this:

pawn Код:
if(floatcmp(1.0, 1.0) == 0)
if(floatcmp(1.0, 1.0) == -1)
if(floatcmp(1.0, 1.0) == 1)
Be the exact same as this:

pawn Код:
if(1.0 == 1.0)
if(1.0 < 1.0)
if(1.0 > 1.0)
What is the difference between using these two methods (floatcmp and operators)? Is one more accurate, or are they just the same (similar to floatdiv)?
Reply
#2

correction
pawn Код:
if(floatcmp(1.0, 1.0) == 0)
if(floatcmp(1.0, 1.5) == -1)
if(floatcmp(1.5, 1.0) == 1)
but to answer you, yes
floatdiv is a different function. simply divides the 2 floats and returning a result
Reply
#3

They're the exact same. If you would open 'include/float.inc', you would see several functions like this:
Код:
stock bool:operator==(Float:oper1, Float:oper2)
    return floatcmp(oper1, oper2) == 0;
They basically make sure that the operators work with floats. In other words, if the compiler finds a '==' with a float in your script, it will replace that operator with the 'floatcmp' function. If you would remove all the 'operator' stocks from 'float.inc', operators would not work anymore with floats.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)