µSer
uSer::SignFormat::OnesComplement Struct Reference

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

#include <uSer.hh>

Detailed Description

Attribute: Store a signed integer in One's Complement 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 y_i} \]

with

\[ y_i = \begin{cases} x_i & x_{k-1} = 0\\ 1-x_i & x_{k-1} = 1 \\ \end{cases} \]

The range for a signed $k$-Bit-Integer in One's complement 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: