Recent changes Random page
GAMING
Gaming
 
WoWWiki
Diablo Wiki
Fallout-The Vault
Grand Theft Wiki
Halopedia
StarCraft Wiki
FFXIclopedia
Resident Evil Wiki
See more...

Float

From NWNWiki

Jump to: navigation, search

[edit] Float

The float keyword defines a variable as a 32-bit floating point number.

Typically, 32-bit floating point numbers can range in value from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative).

[edit] Note

When defining a floating point number, you must include the decimal point and at least one number after the decimal point.

   //Example 

   float fFloat=12.0;  //good
   float fError=12;    //no good

This code will cause a compiler error (ERROR: MISMATCHED TYPES) on the line "float fError=12;".

[edit] Conversion

The float data type can be converted using the following functions.

   // Float To Integer
  
   float fFloat=21.6; 
   int nInteger=FloatToInt(fFloat);

nInteger = 21
References 
FloatToInt


   // Float To String 

   float fFloat=21.6;
   string sString=FloatToString(fFloat);

sString = "21.600000000"
References 
FloatToString
Rate this article:
Share this article: