Divide by 2 - 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: Divide by 2 (
/showthread.php?tid=626589)
Divide by 2 -
pelican1 - 17.01.2017
Hello,
I want to divide a number by 2 but if it became a float after this operation, i'd like to use floatround how i can so check if the result of operation is a float or not
Re: Divide by 2 -
Misiur - 17.01.2017
It won't become a float. All types must be known compile-time, otherwise you'll get an compiler warning of tag mismatch. So, if you divide tagless variable by tagless variable, you'll get tagless result with fraction part discarded: 5 / 2 == 2. If at least one side of operations is a float, then you'll get a float: 5 / 2.0 == 2.5. So, if you do:
You'll get a tag mismatch.