Question In Regards To 'floatcmp' Usage? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question In Regards To 'floatcmp' Usage? (
/showthread.php?tid=517428)
Question In Regards To 'floatcmp' Usage? -
DrakeX - 04.06.2014
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)?
Re: Question In Regards To 'floatcmp' Usage? -
park4bmx - 04.06.2014
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
Re: Question In Regards To 'floatcmp' Usage? -
Basssiiie - 04.06.2014
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.