Difference between revisions of "Float keyword"
(→Persistence) |
m (→Persistence) |
||
Line 72: | Line 72: | ||
* [[GetEffectFloat]] | * [[GetEffectFloat]] | ||
* [[GetEventFloat]] | * [[GetEventFloat]] | ||
− | |||
<!-- == Special == --> | <!-- == Special == --> |
Revision as of 23:24, 19 November 2009
The float type represents a signed 32-bit floating-point value between -3.402823e38 and 3.402823e38. The default value is 0.0.
Literals
A literal is a textual representation of a particular value of a type.
A float literal is decimal (base 10) and consists of a string of decimal digits (0-9) followed by a decimal point. Optionally one or more decimal digits (the mantissa) and/or a letter "f" suffix can follow the decimal point.
// valid float literals float fLiteral1 = 1.; float fLiteral2 = 1.2; float fLiteral3 = 1.f; float fLiteral4 = 1.2f; // invalid float literals float fInvalid1 = 1; // causes "Mismatched type" error float fInvalid2 = .1; // causes "Unknown state in compiler" error float fInvalid3 = 1f; // causes "Parsing variable list" error float fInvalid4 = .1f; // causes "Unknown state in compiler" error
Note that since the decimal point is required even when there is no mantissa the "f" suffix is in fact totally redundant.
Conversion
Explicit
The following functions can be used to convert another data type to a float:
The following functions can be used to convert a float to another data type:
Implicit
If an int and a float are mixed in an arithmetic expression the int is implicitly converted to a float without needing to use the IntToFloat function.
This is true whether the values are literals (above), variable values or values returned by functions.
Persistence
The following functions allow a float to exist outside of the scope of the current script by storing it on an object, effect or event:
The following functions allow a location which exist outside of the scope of the current script to be used in the current script by retrieving it from an object, effect or event: