µSer
uSer::SignFormat::TwosComplement Struct Reference

Attribute: Store a signed integer in Two's Complement format. More...

#include <uSer.hh>

Detailed Description

Attribute: Store a signed integer in Two's Complement format.

This is the most popular format, used on x86, AVR, ARM. 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 = \sum_{i=0}^{k-2}{2^i \cdot x_i} - \begin{cases} 0 & x_{k-1} = 0\\ 2^{k-1} & x_{k-1} = 1 \\ \end{cases} \]

The range for a signed $k$-Bit-Integer with Two's Complement is $[-2^{k-1};2^{k-1}-1]$.


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