Floating Point Standard Types
In contrast to Integers, Floats are used to represent numerical values that can contain decimals or fractional parts. This makes floats more versatile, but comes with drawbacks such as slower performance than integers and less well-defined precision.
Elements provides two different floating point types with difference sizes (32 and 64 bits). Different from integers, the size does not so much determine the range of numbers that the type can hold, but rather their precision – that is, how many digits of accuracy are provided.
Both float types are defined in the RemObjects.Elements.System
namespace – which is in scope by default and does not have to be used/imported manually. However, the namespace name can be used to prefix the type names, where necessary, to avoid ambiguities.
In addition to the type core names and their aliases, C# also provides the float
and double
keywords to refer to these same types. Swift also defines additional aliases in the Swift
namespace via the Swift Base Library.
Probably the most commonly used floating point type is Double
.
Name | Description | Aliases | C# Keyword | Swift Aliases |
---|---|---|---|---|
Single | A 32-bit single precision floating point type | float | Float, Float32 | |
Double | A 64-bit double precision floating point type | double | Float64 |
See Also
- Integers
- Floating Point Numbers on Wikipedia