Atmel Software Framework

fixed.cpp File Reference

ASF Sensor API fixed point data type.

This header defines a fixed-point data type and associated arithmetic operations. The fixed type approximates fractional quantities using a pair of integers, designated as the mantissa and exponent, such that \( n2^{-q} \) given integer exponent q and integer mantissa n

Because exponent q is a power of 2 it can also be understood as the number of binary digits into n where the binary point is placed. And since mantissa n is a factor of a power of two, it is only necessary to store the mantissa and the number of fractional bits. This is also known as Q number format.

The mantissa is stored and operated on as a signed two's complement number, where Q specifies the number of fractional bits and, by implication, the location of a virtual fixed decimal point within the mantissa.

Copyright (c) 2011-2012 Atmel Corporation. All rights reserved.

#include "fixed.h"