SHIP:Data Types:Float

From Serious Documentation
Revision as of 19:12, 14 October 2016 by CarltonHeyer (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

See Also

Float

Float Data Types are available in SHIPv5 and onwards, and are single precision IEEE754 floating point values.

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

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