Difference between revisions of "SHIP:Data Types:Float"

From Serious Documentation
Jump to: navigation, search
Line 3: Line 3:
 
*'''[[SHIP:Data_Types|All Data Types]]'''
 
*'''[[SHIP:Data_Types|All Data Types]]'''
 
== {{DataType|Float}} ==
 
== {{DataType|Float}} ==
<onlyinclude>Float Data Types are available in SHIPv5 and onwards, and are [http://en.wikipedia.org/wiki/Single_precision_floating-point_format single precision IEEE754] floating point values.
+
<onlyinclude>Float Data Types are available in {{SHIP_Version_5|SHIPv5}} and onwards, and are [http://en.wikipedia.org/wiki/Single_precision_floating-point_format single precision IEEE754] floating point values.
 
{{DataTypeTableStart|}}
 
{{DataTypeTableStart|}}
|{{DataType|Float}}||A [http://en.wikipedia.org/wiki/Single_precision_floating-point_format single precision IEEE754] 32-bit floating point value.
+
|{{DataType|Float}}||A [http://en.wikipedia.org/wiki/Single_precision_floating-point_format single precision IEEE754] 32-bit floating point value.{{v5}}
 
|}</onlyinclude>
 
|}</onlyinclude>
  

Revision as of 11:40, 9 July 2014

See Also

Float

Float Data Types are available in Template:SHIP Version 5 and onwards, and are single precision IEEE754 floating point values.

Data Type Description
Float A single precision IEEE754 32-bit floating point value.Badge SHIPv5.gif

Float constants in SHIPTide must be written with a decimal point, at least one digit before and one digit after the decimal point, with a trailing "f".

Examples of Float constants:

  • 1.0f is 1.0
  • -2.324f is -2.324
  • .3f is invalid, since there are no digits in front of the decimal point; add a leading 0
  • 1f is invalid, since there is no decimal point nor trailing digits after the decimal point
  • 1.f is invalid, since there are no trailing digits after the decimal point

Casting Rules

From To Description
Float Byte fractional elements removed, fit within the Byte range
Float Short fractional elements removed, fit within the Short range
Float Integer fractional elements removed
Float Boolean a value of false if exactly 0.0f, otherwise true
Float Byte fractional elements removed, fit within the Byte range
Byte Float simple cast
Short Float simple cast
Integer Float simple cast, but limited to maximum and minimum Float range which is smaller than Integer
Boolean Float a value of 0.0f for false and 1.0f for true