float

The float type

In NBC the float type is a 32-bit IEEE 754 single precision floating point representation. This is a binary format that occupies 32 bits (4 bytes) and its significand has a precision of 24 bits (about 7 decimal digits).

Floating point arithmetic will be slower than integer operations but if you need to easily store decimal values the float type is your best option. The standard NXT firmware provides the sqrt function which benefits from the ability to use the float type. In the enhanced NBC/NXC firmware there are many more native opcodes from the standard C math library which are designed to work with floats.

  dseg segment
    pi float 3.14159
    e  float 2.71828
    s2 float 1.4142
  dseg ends

Generated by  doxygen 1.6.2