GNU Compiler Collection (GCC) Internals: Fixed-point fractional library routines |
---|
Next: Exception handling routines, Previous: Decimal float library routines, Up: Libgcc [Contents][Index]
The software fixed-point library implements fixed-point fractional arithmetic, and is only activated on selected targets.
For ease of comprehension fract
is an alias for the
_Fract
type, accum
an alias for _Accum
, and
sat
an alias for _Sat
.
For illustrative purposes, in this section the fixed-point fractional type
short fract
is assumed to correspond to machine mode QQmode
;
unsigned short fract
to UQQmode
;
fract
to HQmode
;
unsigned fract
to UHQmode
;
long fract
to SQmode
;
unsigned long fract
to USQmode
;
long long fract
to DQmode
;
and unsigned long long fract
to UDQmode
.
Similarly the fixed-point accumulator type
short accum
corresponds to HAmode
;
unsigned short accum
to UHAmode
;
accum
to SAmode
;
unsigned accum
to USAmode
;
long accum
to DAmode
;
unsigned long accum
to UDAmode
;
long long accum
to TAmode
;
and unsigned long long accum
to UTAmode
.
These functions return the sum of a and b.
These functions return the sum of a and b with signed saturation.
These functions return the sum of a and b with unsigned saturation.
These functions return the difference of a and b;
that is,
a - b
.
These functions return the difference of a and b with signed
saturation; that is,
a - b
.
These functions return the difference of a and b with unsigned
saturation; that is,
a - b
.
These functions return the product of a and b.
These functions return the product of a and b with signed saturation.
These functions return the product of a and b with unsigned saturation.
These functions return the quotient of the signed division of a and b.
These functions return the quotient of the unsigned division of a and b.
These functions return the quotient of the signed division of a and b with signed saturation.
These functions return the quotient of the unsigned division of a and b with unsigned saturation.
These functions return the negation of a.
These functions return the negation of a with signed saturation.
These functions return the negation of a with unsigned saturation.
These functions return the result of shifting a left by b bits.
These functions return the result of arithmetically shifting a right by b bits.
These functions return the result of logically shifting a right by b bits.
These functions return the result of shifting a left by b bits with signed saturation.
These functions return the result of shifting a left by b bits with unsigned saturation.
The following functions implement fixed-point comparisons. These functions implement a low-level compare, upon which the higher level comparison operators (such as less than and greater than or equal to) can be constructed. The returned values lie in the range zero to two, to allow the high-level operators to be implemented by testing the returned result using either signed or unsigned comparison.
These functions perform a signed or unsigned comparison of a and b (depending on the selected machine mode). If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1.
These functions convert from fractional and signed non-fractionals to fractionals and signed non-fractionals, without saturation.
The functions convert from fractional and signed non-fractionals to fractionals, with saturation.
These functions convert from fractionals to unsigned non-fractionals; and from unsigned non-fractionals to fractionals, without saturation.
These functions convert from unsigned non-fractionals to fractionals, with saturation.
Next: Exception handling routines, Previous: Decimal float library routines, Up: Libgcc [Contents][Index]