µSer
uSer::SignFormat::SignedMagnitude Struct Reference

Attribute: Store a signed integer in Signed-Magnitude format. More...

#include <uSer.hh>

Detailed Description

Attribute: Store a signed integer in Signed-Magnitude format.

When applied to a $k$-Bit-Integer, let $x_{k-1},x_{k-2},\dots,x_0 $ denote its raw bits with $x_{k-1}$ being the most significant and $x_0$ the least significant one. Then $x_{k-1}$ is the sign bit. The value of the integer is:

\[ X = (1 - 2 \cdot x_{k-1}) \cdot \sum_{i=0}^{k-2}{2^i \cdot x_i} \]

The range for a signed $k$-Bit-Integer in Signed-Magnitude format is $[-2^{k-1}+1;2^{k-1}-1]$. There are 2 representations for zero.


The documentation for this struct was generated from the following file: