# EmCan Protocol Specification

## 48 bit Floating Point Format

Last updated 6 March 2013

The 48 bits are divided into three fields, the **sign**,
**exponent**, and **mantissa**.

The **sign** field is in bit 47 (the most significant bit) and is 1
bit wide. A value of 0 means the overall number is zero or
positive, and a value of 1 means it is negative.

The **exponent** field is in bits 46:32 and is 15 bits wide.
It is a unsigned integer value indicating the power of 2 to be applied to
the mantissa value, plus 16384. For example, a value of 16387 means
the mantissa is to be scaled by 2^{3} = 8, and 16380 that the
scale factor is 2^{-4} = 1/16. The special value of 0 is
reserved for when the overall number value is zero. For non-zero
values, the exponent field range is therefore 1-32767, which is a scaling
range of 2^{-16383} to 2^{16383}.

The **mantissa** field is in bits 31:0 and is 32 bits wide. It
is the most significant 32 fraction bits of a number with the units bit 1
and all higher bits 0. Put another way, there is a implied integer
one and binary point immediately to the left of the mantissa value.
The mantissa field therefore represents a value from 1 up to but not
including 2.

The special case of all 48 bits 0 indicates the value zero.

To determine the overall value of the 48 bit floating point number,
perform the following steps:

- Check for all bits 0. If so, the overall all value is 0
and the remaining steps are skipped.
- Determine the value represented by the mantissa field. This is
always greater than or equal to 1 and less than 2.
- Multiply the value from step 2 by the scale factor represented by
the exponent field.
- If the sign bit is 0, don't alter the number. If the sign bit is
1, negate the number.