AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   int to float? (https://forums.alliedmods.net/showthread.php?t=28682)

cheshire- 05-20-2006 09:58

int to float?
 
I need to turn integers into floats so that they can be manipulated correctly, but i cant find a num_to_float or int_to_float function or something similar. Is there another way besides converting them to a string then a float?

VEN 05-20-2006 10:32

Use float(integer):
Code:
new integer = 123 new Float:x = float(integer)

Hawk552 05-20-2006 14:28

You can just cast it:

Code:
    new iNum = 0     new Float:flNum = Float:iNum

BAILOPAN 05-20-2006 15:29

Quote:

Originally Posted by Hawk552
You can just cast it:

Code:
    new iNum = 0     new Float:flNum = Float:iNum

In fact, that is wrong. You must use float(). A re-tag is a bitstring copy, not a type cast.

cheshire- 05-20-2006 21:06

thank you thank you


All times are GMT -4. The time now is 16:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.