|
| char * | hktoa (short accum x, char *buf, unsigned char mode) |
| |
| char * | hrtoa (short fract x, char *buf, unsigned char mode) |
| |
| char * | ktoa (accum x, char *buf, unsigned char mode) |
| |
| char * | rtoa (fract x, char *buf, unsigned char mode) |
| |
| char * | uhktoa (unsigned short accum x, char *buf, unsigned char mode) |
| |
| char * | uhrtoa (unsigned short fract x, char *buf, unsigned char mode) |
| |
| char * | uktoa (unsigned accum x, char *buf, unsigned char mode) |
| |
| char * | urtoa (unsigned fract x, char *buf, unsigned char mode) |
| |
|
| short fract | abshr (short fract val) |
| |
| fract | absr (fract val) |
| |
| long fract | abslr (long fract val) |
| |
| long long fract | absllr (long long fract val) |
| |
| short accum | abshk (short accum val) |
| |
| accum | absk (accum val) |
| |
| long accum | abslk (long accum val) |
| |
| long long accum | absllk (long long accum val) |
| |
|
| signed char | bitshr (short fract val) |
| |
| unsigned char | bitsuhr (unsigned short fract val) |
| |
| int | bitsr (fract val) |
| |
| unsigned int | bitsur (unsigned fract val) |
| |
| long | bitslr (long fract val) |
| |
| unsigned long | bitsulr (unsigned long fract val) |
| |
| long long | bitsllr (long long fract val) |
| |
| unsigned long long | bitsullr (unsigned long long fract val) |
| |
| int | bitshk (short accum val) |
| |
| unsigned int | bitsuhk (unsigned short accum val) |
| |
| long | bitsk (accum val) |
| |
| unsigned long | bitsuk (unsigned accum val) |
| |
| long long | bitslk (long accum val) |
| |
| unsigned long long | bitsulk (unsigned long accum val) |
| |
| long long | bitsllk (long long accum val) |
| |
| unsigned long long | bitsullk (unsigned long long accum val) |
| |
|
| short fract | hrbits (signed char val) |
| |
| unsigned short fract | uhrbits (unsigned char val) |
| |
| fract | rbits (int val) |
| |
| unsigned fract | urbits (unsigned int val) |
| |
| long fract | lrbits (long val) |
| |
| unsigned long fract | ulrbits (unsigned long val) |
| |
| long long fract | llrbits (long long val) |
| |
| unsigned long long fract | ullrbits (unsigned long long val) |
| |
| short accum | hkbits (int val) |
| |
| unsigned short accum | uhkbits (unsigned int val) |
| |
| accum | kbits (long val) |
| |
| unsigned accum | ukbits (unsigned long val) |
| |
| long accum | lkbits (long long val) |
| |
| unsigned long accum | ulkbits (unsigned long long val) |
| |
| long long accum | llkbits (long long val) |
| |
| unsigned long long accum | ullkbits (unsigned long long val) |
| |
|
| fract | rdivi (int num, int denom) |
| |
| long fract | lrdivi (long int num, long int denom) |
| |
| unsigned fract | urdivi (unsigned int num, unsigned int denom) |
| |
| unsigned long fract | ulrdivi (unsigned long int num, unsigned long int denom) |
| |
|
| short fract | roundhr (short fract val, int bit) |
| |
| unsigned short fract | rounduhr (unsigned short fract val, int bit) |
| |
| fract | roundr (fract val, int bit) |
| |
| unsigned fract | roundur (unsigned fract val, int bit) |
| |
| long fract | roundlr (long fract val, int bit) |
| |
| unsigned long fract | roundulr (unsigned long fract val, int bit) |
| |
| long long fract | roundllr (long long fract val, int bit) |
| |
| unsigned long long fract | roundullr (unsigned long long fract val, int bit) |
| |
| short accum | roundhk (short accum val, int bit) |
| |
| unsigned short accum | rounduhk (unsigned short accum val, int bit) |
| |
| accum | roundk (accum val, int bit) |
| |
| unsigned accum | rounduk (unsigned accum val, int bit) |
| |
| long accum | roundlk (long accum val, int bit) |
| |
| unsigned long accum | roundulk (unsigned long accum val, int bit) |
| |
| long long accum | roundllk (long long accum val, int bit) |
| |
| unsigned long long accum | roundullk (unsigned long long accum val, int bit) |
| |
|
| accum | acosk (accum x) |
| |
| unsigned accum | acosuk (unsigned accum x) |
| |
| accum | asink (accum x) |
| |
| unsigned accum | asinuk (unsigned accum x) |
| |
| accum | atank (accum x) |
| |
| unsigned accum | atanuk (unsigned accum x) |
| |
| unsigned fract | atanur (unsigned fract x) |
| |
| accum | exp2k (accum x) |
| |
| unsigned accum | exp2uk (unsigned accum x) |
| |
| unsigned fract | exp2m1ur (unsigned fract x) |
| |
| accum | log2uk (unsigned accum x) |
| |
| short accum | log2uhk (unsigned short accum x) |
| |
| unsigned short fract | log21puhr (unsigned short fract x) |
| |
| unsigned fract | log21pur (unsigned fract x) |
| |
| accum | cospi2k (accum deg) |
| |
| accum | sinpi2k (accum deg) |
| |
| fract | sinuhk_deg (unsigned short accum deg) |
| |
| fract | cosuhk_deg (unsigned short accum deg) |
| |
| unsigned fract | sinpi2ur (unsigned fract x) |
| |
| short accum | sqrthk (short accum radic) |
| |
| short fract | sqrthr (short fract radic) |
| |
| accum | sqrtk (accum radic) |
| |
| long fract | sqrtlr (long fract radic) |
| |
| fract | sqrtr (fract radic) |
| |
| unsigned short accum | sqrtuhk (unsigned short accum radic) |
| |
| unsigned short fract | sqrtuhr (unsigned short fract radic) |
| |
| unsigned accum | sqrtuk (unsigned accum radic) |
| |
| unsigned long fract | sqrtulr (unsigned long fract radic) |
| |
| unsigned fract | sqrtur (unsigned fract radic) |
| |
|
| static short fract | pgm_read_hr (const short fract *addr) |
| |
| static unsigned short fract | pgm_read_uhr (const unsigned short fract *addr) |
| |
| static fract | pgm_read_r (const fract *addr) |
| |
| static unsigned fract | pgm_read_ur (const unsigned fract *addr) |
| |
| static long fract | pgm_read_lr (const long fract *addr) |
| |
| static unsigned long fract | pgm_read_ulr (const unsigned long fract *addr) |
| |
| static long long fract | pgm_read_llr (const long long fract *addr) |
| |
| static unsigned long long fract | pgm_read_ullr (const unsigned long long fract *addr) |
| |
| static short accum | pgm_read_hk (const short accum *addr) |
| |
| static unsigned short accum | pgm_read_uhk (const unsigned short accum *addr) |
| |
| static accum | pgm_read_k (const accum *addr) |
| |
| static unsigned accum | pgm_read_uk (const unsigned accum *addr) |
| |
| static long accum | pgm_read_lk (const long accum *addr) |
| |
| static unsigned long accum | pgm_read_ulk (const unsigned long accum *addr) |
| |
| static long long accum | pgm_read_llk (const long long accum *addr) |
| |
| static unsigned long long accum | pgm_read_ullk (const unsigned long long accum *addr) |
| |
|
| void | eeprom_write_hr (short fract *__p, short fract __value) |
| |
| void | eeprom_write_uhr (unsigned short fract *__p, unsigned short fract __value) |
| |
| void | eeprom_write_r (fract *__p, fract __value) |
| |
| void | eeprom_write_ur (unsigned fract *__p, unsigned fract __value) |
| |
| void | eeprom_write_lr (long fract *__p, long fract __value) |
| |
| void | eeprom_write_ulr (unsigned long fract *__p, unsigned long fract __value) |
| |
| void | eeprom_write_llr (long long fract *__p, long long fract __value) |
| |
| void | eeprom_write_ullr (unsigned long long fract *__p, unsigned long long fract __value) |
| |
| void | eeprom_write_hk (short accum *__p, short accum __value) |
| |
| void | eeprom_write_uhk (unsigned short accum *__p, unsigned short accum __value) |
| |
| void | eeprom_write_k (accum *__p, accum __value) |
| |
| void | eeprom_write_uk (unsigned accum *__p, unsigned accum __value) |
| |
| void | eeprom_write_lk (long accum *__p, long accum __value) |
| |
| void | eeprom_write_ulk (unsigned long accum *__p, unsigned long accum __value) |
| |
| void | eeprom_write_llk (long long accum *__p, long long accum __value) |
| |
| void | eeprom_write_ullk (unsigned long long accum *__p, unsigned long long accum __value) |
| |
|
| void | eeprom_update_hr (short fract *__p, short fract __value) |
| |
| void | eeprom_update_uhr (unsigned short fract *__p, unsigned short fract __value) |
| |
| void | eeprom_update_r (fract *__p, fract __value) |
| |
| void | eeprom_update_ur (unsigned fract *__p, unsigned fract __value) |
| |
| void | eeprom_update_lr (long fract *__p, long fract __value) |
| |
| void | eeprom_update_ulr (unsigned long fract *__p, unsigned long fract __value) |
| |
| void | eeprom_update_llr (long long fract *__p, long long fract __value) |
| |
| void | eeprom_update_ullr (unsigned long long fract *__p, unsigned long long fract __value) |
| |
| void | eeprom_update_hk (short accum *__p, short accum __value) |
| |
| void | eeprom_update_uhk (unsigned short accum *__p, unsigned short accum __value) |
| |
| void | eeprom_update_k (accum *__p, accum __value) |
| |
| void | eeprom_update_uk (unsigned accum *__p, unsigned accum __value) |
| |
| void | eeprom_update_lk (long accum *__p, long accum __value) |
| |
| void | eeprom_update_ulk (unsigned long accum *__p, unsigned long accum __value) |
| |
| void | eeprom_update_llk (long long accum *__p, long long accum __value) |
| |
| void | eeprom_update_ullk (unsigned long long accum *__p, unsigned long long accum __value) |
| |
As an extension, GNU C supports fixed-point types as defined in the N1169 draft of ISO/IEC DTR 18037.
- Since
- avr-gcc v4.8
Two groups of fixed-point data types are added:
- The fract types and the accum types. The data value of a fract type has no integral part, hence values of a fract type are between -1.0 and +1.0.
- The value range of an accum type depends on the number of integral bits in the data type.
Fixed-Point Type Layout
| Const Suffix | Type | Size | Q-Format | Epsilon |
hr | short fract | 1 | s.7 | 7.81·10-3 |
r | fract | 2 | s.15 | 3.05·10-5 |
lr | long fract | 4 | s.31 | 4.66·10-10 |
llr | long long fract | 8 | s.63 | 1.08·10-19 |
hk | short accum | 2 | s8.7 | 7.81·10-3 |
k | accum | 4 | s16.15 | 3.05·10-5 |
lk | long accum | 8 | s32.31 | 4.66·10-10 |
llk | long long accum | 8 | s16.47 | 7.11·10-15 |
uhr | unsigned short fract | 1 | 0.8 | 3.91·10-3 |
ur | unsigned fract | 2 | 0.16 | 1.53·10-5 |
ulr | unsigned long fract | 4 | 0.32 | 2.33·10-10 |
ullr | unsigned long long fract | 8 | 0.64 | 5.42·10-20 |
uhk | unsigned short accum | 2 | 8.8 | 3.91·10-3 |
uk | unsigned accum | 4 | 16.16 | 1.53·10-5 |
ulk | unsigned long accum | 8 | 32.32 | 2.33·10-10 |
ullk | unsigned long long accum | 8 | 16.48 | 3.55·10-15 |
See also some benchmarks.
◆ FXTOA_ALL
Include all significant digits in the result of a fixed-point to decimal ASCII conversion. The result has no trailing zeros.
To be used in the mode parameter of such a conversion. For details and examples, see uktoa().
- Since
- AVR-LibC v2.3
◆ FXTOA_COMMA
The fixed-point to decimal ASCII conversion routines use a comma (,) for the decimal point.
For details and examples, see uktoa().
- Since
- AVR-LibC v2.3
◆ FXTOA_DOT
The fixed-point to decimal ASCII conversion routines use a dot (.) for the decimal point. This is the default, i.e. FXTOA_DOT can be omitted.
For details, and examples, see uktoa().
- Since
- AVR-LibC v2.3
◆ FXTOA_NTZ
A flag to select that the result of a fixed-point to decimal ASCII conversion has no trailing zeros.
To be used in the mode parameter of such a conversion. For details and examples, see uktoa().
- Since
- AVR-LibC v2.3
◆ FXTOA_ROUND
A flag to select rounding to nearest in a fixed-point to decimal ASCII conversion. Rounding mode is the default, i.e. FXTOA_ROUND can be omitted.
To be used in the mode parameter of such a conversion. For details and examples, see uktoa().
- Since
- AVR-LibC v2.3
◆ FXTOA_TRUNC
A flag to select truncation (rounding to zero) in a fixed-point to decimal ASCII conversion.
To be used in the mode parameter of such a conversion. For details and examples, see uktoa().
- Since
- AVR-LibC v2.3
◆ absfx()
Computes the absolute value of fixed-point value val. When the result does not fit into the range of the return type, the result is saturated.
◆ abshk()
| short accum abshk |
( |
short accum |
val | ) |
|
Computes the absolute value of val. When the result does not fit into the range of the return type, the result is saturated.
◆ abshr()
| short fract abshr |
( |
short fract |
val | ) |
|
Computes the absolute value of val. When the result does not fit into the range of the return type, the result is saturated.
◆ absk()
Computes the absolute value of val. When the result does not fit into the range of the return type, the result is saturated.
◆ abslk()
| long accum abslk |
( |
long accum |
val | ) |
|
Computes the absolute value of val. When the result does not fit into the range of the return type, the result is saturated.
◆ absllk()
| long long accum absllk |
( |
long long accum |
val | ) |
|
Computes the absolute value of val. When the result does not fit into the range of the return type, the result is saturated.
◆ absllr()
| long long fract absllr |
( |
long long fract |
val | ) |
|
Computes the absolute value of val. When the result does not fit into the range of the return type, the result is saturated.
◆ abslr()
| long fract abslr |
( |
long fract |
val | ) |
|
Computes the absolute value of val. When the result does not fit into the range of the return type, the result is saturated.
◆ absr()
Computes the absolute value of val. When the result does not fit into the range of the return type, the result is saturated.
◆ acosk()
Compute the arcus cosine of x. The returned value is in the range
[0, π].
For invalid values of x the returned value is -65536 = kbits (0x80000000).
The absolute error is bounded by
5.5·10−5 ≈ 2−14.1.
- Since
- AVR-LibC v2.3
◆ acosuk()
| unsigned accum acosuk |
( |
unsigned accum |
x | ) |
|
Compute the arcus cosine of x. The returned value is in the range
[0, π/2].
For invalid values of x the returned value is 32768 = ukbits (0x80000000).
The absolute error is bounded by
4.6·10−5 ≈ 2−14.4.
- Since
- AVR-LibC v2.3
◆ asink()
Compute the arcus sine of x. The returned value is in the range
[−π/2, π/2].
For invalid values of x the returned value is -65536 = kbits (0x80000000).
The absolute error is bounded by
5.1·10−5 ≈ 2−14.
- Since
- AVR-LibC v2.3
◆ asinuk()
| unsigned accum asinuk |
( |
unsigned accum |
x | ) |
|
Compute the arcus sine of x. The returned value is in the range
[0, π/2].
For invalid values of x the returned value is 32768 = ukbits (0x80000000).
The absolute error is bounded by
4.5·10−5 ≈ 2−14.4.
- Since
- AVR-LibC v2.3
◆ atank()
Compute the arcus tangent of x. The returned value is in the range
(−π/2, π/2≈1.5708).
- Since
- AVR-LibC v2.3
◆ atanuk()
| unsigned accum atanuk |
( |
unsigned accum |
x | ) |
|
Compute the arcus tangent of x. The returned value is in the range
[0, π/2≈1.5708).
- Since
- AVR-LibC v2.3
◆ atanur()
| unsigned fract atanur |
( |
unsigned fract |
x | ) |
|
Compute the arcus tangent of x. The returned value is in the range
[0, π/4≈0.7854].
The absolute error is bounded by
2.6·10−5 ≈ 2−15.
The worst case execution time (WCET) is around 210 cycles when MUL is available, and around 1000 cycles when MUL is not available (measured with avr-gcc v15).
- Since
- AVR-LibC v2.3
◆ bitshk()
| int bitshk |
( |
short accum |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitshr()
| signed char bitshr |
( |
short fract |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsk()
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitslk()
| long long bitslk |
( |
long accum |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsllk()
| long long bitsllk |
( |
long long accum |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsllr()
| long long bitsllr |
( |
long long fract |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitslr()
| long bitslr |
( |
long fract |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsr()
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsuhk()
| unsigned int bitsuhk |
( |
unsigned short accum |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsuhr()
| unsigned char bitsuhr |
( |
unsigned short fract |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsuk()
| unsigned long bitsuk |
( |
unsigned accum |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsulk()
| unsigned long long bitsulk |
( |
unsigned long accum |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsullk()
| unsigned long long bitsullk |
( |
unsigned long long accum |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsullr()
| unsigned long long bitsullr |
( |
unsigned long long fract |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsulr()
| unsigned long bitsulr |
( |
unsigned long fract |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ bitsur()
| unsigned int bitsur |
( |
unsigned fract |
val | ) |
|
Return an integer value of the same size and signedness, and with the same bit representation like val.
◆ cospi2k()
| accum cospi2k |
( |
accum |
deg | ) |
|
Cosine of
x·π/2
radians.
The absolute error is bounded by
4.6·10−5 ≈ 2−14.4.
The worst case execution time (WCET) is around 300 cycles when MUL is available, and around 1400 cycles when MUL is not available.
- Since
- AVR-LibC v2.3
◆ cosuhk_deg()
| fract cosuhk_deg |
( |
unsigned short accum |
deg | ) |
|
Cosine of the angle deg where deg is specified in degrees, i.e. in the range
[0°, 256°).
The returned value is in the range (-1, +1), i.e. is never -1.
The absolute error is bounded by
6.5·10−5 ≈ 2−13.9.
The worst case execution time (WCET) is around 90 cycles.
- Since
- AVR-LibC v2.3
◆ countlsfx()
| int countlsfx |
( |
type |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlshk()
| int countlshk |
( |
short accum |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlshr()
| int countlshr |
( |
short fract |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsk()
| int countlsk |
( |
accum |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlslk()
| int countlslk |
( |
long accum |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsllk()
| int countlsllk |
( |
long long accum |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsllr()
| int countlsllr |
( |
long long fract |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlslr()
| int countlslr |
( |
long fract |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsr()
| int countlsr |
( |
fract |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsuhk()
| int countlsuhk |
( |
unsigned short accum |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsuhr()
| int countlsuhr |
( |
unsigned short fract |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsuk()
| int countlsuk |
( |
unsigned accum |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsulk()
| int countlsulk |
( |
unsigned long accum |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsullk()
| int countlsullk |
( |
unsigned long long accum |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsullr()
| int countlsullr |
( |
unsigned long long fract |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsulr()
| int countlsulr |
( |
unsigned long fract |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ countlsur()
| int countlsur |
( |
unsigned fract |
val | ) |
|
- If
val is non-zero, the return value is the largest integer k for which the expression val << k does not overflow.
- If
val is zero, an integer value is returned that is at least as large as N - 1, where N is the total number of bits of the type of the argument.
◆ eeprom_read_hk()
| short accum eeprom_read_hk |
( |
const short accum * |
__p | ) |
|
Read a short accum from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_hr()
| short fract eeprom_read_hr |
( |
const short fract * |
__p | ) |
|
Read a short fract from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_k()
| accum eeprom_read_k |
( |
const accum * |
__p | ) |
|
Read an accum from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_lk()
| long accum eeprom_read_lk |
( |
const long accum * |
__p | ) |
|
Read a long accum from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_llk()
| long long accum eeprom_read_llk |
( |
const long long accum * |
__p | ) |
|
Read a long long accum from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_llr()
| long long fract eeprom_read_llr |
( |
const long long fract * |
__p | ) |
|
Read a long long fract from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_lr()
| long fract eeprom_read_lr |
( |
const long fract * |
__p | ) |
|
Read a long fract from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_r()
| fract eeprom_read_r |
( |
const fract * |
__p | ) |
|
Read a fract from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_uhk()
| unsigned short accum eeprom_read_uhk |
( |
const unsigned short accum * |
__p | ) |
|
Read an unsigned short accum from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_uhr()
| unsigned short fract eeprom_read_uhr |
( |
const unsigned short fract * |
__p | ) |
|
Read an unsigned short fract from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_uk()
| unsigned accum eeprom_read_uk |
( |
const unsigned accum * |
__p | ) |
|
Read an unsigned accum from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_ulk()
| unsigned long accum eeprom_read_ulk |
( |
const unsigned long accum * |
__p | ) |
|
Read an unsigned long accum from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_ullk()
| unsigned long long accum eeprom_read_ullk |
( |
const unsigned long long accum * |
__p | ) |
|
Read an unsigned long long accum from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_ullr()
| unsigned long long fract eeprom_read_ullr |
( |
const unsigned long long fract * |
__p | ) |
|
Read an unsigned long long fract from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_ulr()
| unsigned long fract eeprom_read_ulr |
( |
const unsigned long fract * |
__p | ) |
|
Read an unsigned long fract from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_read_ur()
| unsigned fract eeprom_read_ur |
( |
const unsigned fract * |
__p | ) |
|
Read an unsigned fract from EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_hk()
| void eeprom_update_hk |
( |
short accum * |
__p, |
|
|
short accum |
__value |
|
) |
| |
Update a short accum at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_hr()
| void eeprom_update_hr |
( |
short fract * |
__p, |
|
|
short fract |
__value |
|
) |
| |
Update a short fract at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_k()
| void eeprom_update_k |
( |
accum * |
__p, |
|
|
accum |
__value |
|
) |
| |
Update an accum at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_lk()
| void eeprom_update_lk |
( |
long accum * |
__p, |
|
|
long accum |
__value |
|
) |
| |
Update a long accum at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_llk()
| void eeprom_update_llk |
( |
long long accum * |
__p, |
|
|
long long accum |
__value |
|
) |
| |
Update a long long accum at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_llr()
| void eeprom_update_llr |
( |
long long fract * |
__p, |
|
|
long long fract |
__value |
|
) |
| |
Update a long long fract at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_lr()
| void eeprom_update_lr |
( |
long fract * |
__p, |
|
|
long fract |
__value |
|
) |
| |
Update a long fract at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_r()
| void eeprom_update_r |
( |
fract * |
__p, |
|
|
fract |
__value |
|
) |
| |
Update a fract at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_uhk()
| void eeprom_update_uhk |
( |
unsigned short accum * |
__p, |
|
|
unsigned short accum |
__value |
|
) |
| |
Update an unsigned short accum at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_uhr()
| void eeprom_update_uhr |
( |
unsigned short fract * |
__p, |
|
|
unsigned short fract |
__value |
|
) |
| |
Update an unsigned short fract at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_uk()
| void eeprom_update_uk |
( |
unsigned accum * |
__p, |
|
|
unsigned accum |
__value |
|
) |
| |
Update an unsigned accum at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_ulk()
| void eeprom_update_ulk |
( |
unsigned long accum * |
__p, |
|
|
unsigned long accum |
__value |
|
) |
| |
Update an unsigned long accum at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_ullk()
| void eeprom_update_ullk |
( |
unsigned long long accum * |
__p, |
|
|
unsigned long long accum |
__value |
|
) |
| |
Update an unsigned long long accum at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_ullr()
| void eeprom_update_ullr |
( |
unsigned long long fract * |
__p, |
|
|
unsigned long long fract |
__value |
|
) |
| |
Update an unsigned long long fract at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_ulr()
| void eeprom_update_ulr |
( |
unsigned long fract * |
__p, |
|
|
unsigned long fract |
__value |
|
) |
| |
Update an unsigned long fract at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_update_ur()
| void eeprom_update_ur |
( |
unsigned fract * |
__p, |
|
|
unsigned fract |
__value |
|
) |
| |
Update an unsigned fract at EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_hk()
| void eeprom_write_hk |
( |
short accum * |
__p, |
|
|
short accum |
__value |
|
) |
| |
Write a short accum to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_hr()
| void eeprom_write_hr |
( |
short fract * |
__p, |
|
|
short fract |
__value |
|
) |
| |
Write a short fract to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_k()
| void eeprom_write_k |
( |
accum * |
__p, |
|
|
accum |
__value |
|
) |
| |
Write an accum to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_lk()
| void eeprom_write_lk |
( |
long accum * |
__p, |
|
|
long accum |
__value |
|
) |
| |
Write a long accum to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_llk()
| void eeprom_write_llk |
( |
long long accum * |
__p, |
|
|
long long accum |
__value |
|
) |
| |
Write a long long accum to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_llr()
| void eeprom_write_llr |
( |
long long fract * |
__p, |
|
|
long long fract |
__value |
|
) |
| |
Write a long long fract to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_lr()
| void eeprom_write_lr |
( |
long fract * |
__p, |
|
|
long fract |
__value |
|
) |
| |
Write a long fract to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_r()
| void eeprom_write_r |
( |
fract * |
__p, |
|
|
fract |
__value |
|
) |
| |
Write a fract to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_uhk()
| void eeprom_write_uhk |
( |
unsigned short accum * |
__p, |
|
|
unsigned short accum |
__value |
|
) |
| |
Write an unsigned short accum to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_uhr()
| void eeprom_write_uhr |
( |
unsigned short fract * |
__p, |
|
|
unsigned short fract |
__value |
|
) |
| |
Write an unsigned short fract to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_uk()
| void eeprom_write_uk |
( |
unsigned accum * |
__p, |
|
|
unsigned accum |
__value |
|
) |
| |
Write an unsigned accum to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_ulk()
| void eeprom_write_ulk |
( |
unsigned long accum * |
__p, |
|
|
unsigned long accum |
__value |
|
) |
| |
Write an unsigned long accum to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_ullk()
| void eeprom_write_ullk |
( |
unsigned long long accum * |
__p, |
|
|
unsigned long long accum |
__value |
|
) |
| |
Write an unsigned long long accum to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_ullr()
| void eeprom_write_ullr |
( |
unsigned long long fract * |
__p, |
|
|
unsigned long long fract |
__value |
|
) |
| |
Write an unsigned long long fract to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_ulr()
| void eeprom_write_ulr |
( |
unsigned long fract * |
__p, |
|
|
unsigned long fract |
__value |
|
) |
| |
Write an unsigned long fract to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ eeprom_write_ur()
| void eeprom_write_ur |
( |
unsigned fract * |
__p, |
|
|
unsigned fract |
__value |
|
) |
| |
Write an unsigned fract to EEPROM address __p.
- Since
- AVR-LibC v2.3
◆ exp2k()
Compute
2x
with saturation.
The WCET is at least the one of exp2m1ur().
- Since
- AVR-LibC v2.3
◆ exp2m1ur()
| unsigned fract exp2m1ur |
( |
unsigned fract |
x | ) |
|
Compute
2x − 1.
The returned value is in the range [0, 1).
The absolute error is bounded by
2.2·10−5 ≈ 2−15.4.
The worst case execution time (WCET) is around 200 cycles when MUL is available, and around 1000 cycles when MUL is not available (measured with avr-gcc v15).
- Since
- AVR-LibC v2.3
◆ exp2uk()
| unsigned accum exp2uk |
( |
unsigned accum |
x | ) |
|
Compute
2x
with saturation.
The WCET is at least the one of exp2m1ur().
- Since
- AVR-LibC v2.3
◆ hkbits()
| short accum hkbits |
( |
int |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ hktoa()
| char * hktoa |
( |
short accum |
x, |
|
|
char * |
buf, |
|
|
unsigned char |
mode |
|
) |
| |
Convert fixed-point value x to a decimal ASCII representation. The result is written to buf, and the user is responsible for providing enough memory in buf. Returns buf.
For the meaning of mode, and for the (maximal) number of character written by this function, see uktoa().
- Since
- AVR-LibC v2.3
◆ hrbits()
| short fract hrbits |
( |
signed char |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ hrtoa()
| char * hrtoa |
( |
short fract |
x, |
|
|
char * |
buf, |
|
|
unsigned char |
mode |
|
) |
| |
Convert fixed-point value x to a decimal ASCII representation. The result is written to buf, and the user is responsible for providing enough memory in buf. Returns buf.
For the meaning of mode, and for the (maximal) number of character written by this function, see uktoa().
- Since
- AVR-LibC v2.3
◆ kbits()
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ ktoa()
| char * ktoa |
( |
accum |
x, |
|
|
char * |
buf, |
|
|
unsigned char |
mode |
|
) |
| |
Convert fixed-point value x to a decimal ASCII representation. The result is written to buf, and the user is responsible for providing enough memory in buf. Returns buf.
For the meaning of mode, and for the (maximal) number of character written by this function, see uktoa().
- Since
- AVR-LibC v2.3
◆ lkbits()
| long accum lkbits |
( |
long long |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ llkbits()
| long long accum llkbits |
( |
long long |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ llrbits()
| long long fract llrbits |
( |
long long |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ log21puhr()
| unsigned short fract log21puhr |
( |
unsigned short fract |
x | ) |
|
Return
log2(1 + x),
the logarithm to base 2 of the value 1 + x. The result is in the range [0, 1).
The absolute error is bounded by
4.3·10−3 ≈ 2−7.5.
The worst case execution time (WCET) is around 25 cycles when MUL is available, and around 340 cycles when MUL is not available.
- Since
- AVR-LibC v2.3
◆ log21pur()
| unsigned fract log21pur |
( |
unsigned fract |
x | ) |
|
Return
log2(1 + x),
the logarithm to base 2 of the value 1 + x. The result is in the range [0, 1).
The absolute error is bounded by
3·10−5 ≈ 2−15.
The worst case execution time (WCET) is around 250 cycles when MUL is available, and around 1300 cycles when MUL is not available.
- Since
- AVR-LibC v2.3
◆ log2uhk()
| short accum log2uhk |
( |
unsigned short accum |
x | ) |
|
Return
log2(x),
the logarithm to base 2 of the value x. The returned value for x = 0 is -128.
The absolute error is bounded by
8·10−3 ≈ 2−7.
The worst case execution time (WCET) is around 60 cycles plus the WCET of log21puhr().
- Since
- AVR-LibC v2.3
◆ log2uk()
| accum log2uk |
( |
unsigned accum |
x | ) |
|
Returns
log2(x),
the logarithm to base 2 of the value x. The returned value for x = 0 is -32768.
The absolute error is bounded by
4.5·10−5 ≈ 2−14.5.
The worst case execution time (WCET) is around 150 cycles more than the WCET of log21pur().
- Since
- AVR-LibC v2.3
◆ lrbits()
| long fract lrbits |
( |
long |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ lrdivi()
| long fract lrdivi |
( |
long int |
num, |
|
|
long int |
denom |
|
) |
| |
The lrdivi() function computes the value of num/denom and returns the result of the long fract type. The return value is rounded towards zero, and is saturated on overflow. If denom is zero, the behavior is undefined.
- Since
- AVR-LibC v2.3
◆ pgm_read_hk()
| static short accum pgm_read_hk |
( |
const short accum * |
addr | ) |
|
|
inlinestatic |
Read a short accum from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_hk_far()
Read a short accum from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_hr()
| static short fract pgm_read_hr |
( |
const short fract * |
addr | ) |
|
|
inlinestatic |
Read a short fract from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_hr_far()
Read a short fract from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_k()
| static accum pgm_read_k |
( |
const accum * |
addr | ) |
|
|
inlinestatic |
Read an accum from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_k_far()
Read an accum from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_lk()
| static long accum pgm_read_lk |
( |
const long accum * |
addr | ) |
|
|
inlinestatic |
Read a long accum from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_lk_far()
Read a long accum from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_llk()
| static long long accum pgm_read_llk |
( |
const long long accum * |
addr | ) |
|
|
inlinestatic |
Read a long long accum from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_llk_far()
Read a long long accum from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_llr()
| static long long fract pgm_read_llr |
( |
const long long fract * |
addr | ) |
|
|
inlinestatic |
Read a long long fract from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_llr_far()
Read a long long fract from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_lr()
| static long fract pgm_read_lr |
( |
const long fract * |
addr | ) |
|
|
inlinestatic |
Read a long fract from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_lr_far()
Read a long fract from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_r()
| static fract pgm_read_r |
( |
const fract * |
addr | ) |
|
|
inlinestatic |
Read a fract from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_r_far()
Read a fract from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_uhk()
| static unsigned short accum pgm_read_uhk |
( |
const unsigned short accum * |
addr | ) |
|
|
inlinestatic |
Read an unsigned short accum from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_uhk_far()
| static unsigned short accum pgm_read_uhk_far |
( |
uint_farptr_t |
addr | ) |
|
|
inlinestatic |
Read an unsigned short accum from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_uhr()
| static unsigned short fract pgm_read_uhr |
( |
const unsigned short fract * |
addr | ) |
|
|
inlinestatic |
Read an unsigned short fract from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_uhr_far()
| static unsigned short fract pgm_read_uhr_far |
( |
uint_farptr_t |
addr | ) |
|
|
inlinestatic |
Read an unsigned short fract from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_uk()
| static unsigned accum pgm_read_uk |
( |
const unsigned accum * |
addr | ) |
|
|
inlinestatic |
Read an unsigned accum from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_uk_far()
Read an unsigned accum from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_ulk()
| static unsigned long accum pgm_read_ulk |
( |
const unsigned long accum * |
addr | ) |
|
|
inlinestatic |
Read an unsigned long accum from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_ulk_far()
| static unsigned long accum pgm_read_ulk_far |
( |
uint_farptr_t |
addr | ) |
|
|
inlinestatic |
Read an unsigned long accum from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_ullk()
| static unsigned long long accum pgm_read_ullk |
( |
const unsigned long long accum * |
addr | ) |
|
|
inlinestatic |
Read an unsigned long long accum from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_ullk_far()
| static unsigned long long accum pgm_read_ullk_far |
( |
uint_farptr_t |
addr | ) |
|
|
inlinestatic |
Read an unsigned long long accum from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_ullr()
| static unsigned long long fract pgm_read_ullr |
( |
const unsigned long long fract * |
addr | ) |
|
|
inlinestatic |
Read an unsigned long long fract from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_ullr_far()
| static unsigned long long fract pgm_read_ullr_far |
( |
uint_farptr_t |
addr | ) |
|
|
inlinestatic |
Read an unsigned long long fract from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_ulr()
| static unsigned long fract pgm_read_ulr |
( |
const unsigned long fract * |
addr | ) |
|
|
inlinestatic |
Read an unsigned long fract from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_ulr_far()
| static unsigned long fract pgm_read_ulr_far |
( |
uint_farptr_t |
addr | ) |
|
|
inlinestatic |
Read an unsigned long fract from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_ur()
| static unsigned fract pgm_read_ur |
( |
const unsigned fract * |
addr | ) |
|
|
inlinestatic |
Read an unsigned fract from 16-bit address addr. The address is in the lower 64 KiB of program memory.
- Since
- AVR-LibC v2.3
◆ pgm_read_ur_far()
Read an unsigned fract from far address addr. The address is in the program memory.
- Since
- AVR-LibC v2.3
◆ rbits()
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ rdivi()
| fract rdivi |
( |
int |
num, |
|
|
int |
denom |
|
) |
| |
The rdivi() function computes the value num/denom and returns the result of the fract type. The return value is rounded towards zero, and is saturated on overflow. If denom is zero, the behavior is undefined.
- Since
- AVR-LibC v2.3
◆ roundfx()
| type roundfx |
( |
type |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
As an extension, bit may be in the range -IBIT < bit < FBIT. For example, bit = -1 rounds to an even value.
◆ roundhk()
| short accum roundhk |
( |
short accum |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
As an extension, bit may be in the range -IBIT < bit < FBIT. For example, bit = -1 rounds to an even value.
◆ roundhr()
| short fract roundhr |
( |
short fract |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
◆ roundk()
| accum roundk |
( |
accum |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
As an extension, bit may be in the range -IBIT < bit < FBIT. For example, bit = -1 rounds to an even value.
◆ roundlk()
| long accum roundlk |
( |
long accum |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
As an extension, bit may be in the range -IBIT < bit < FBIT. For example, bit = -1 rounds to an even value.
◆ roundllk()
| long long accum roundllk |
( |
long long accum |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
As an extension, bit may be in the range -IBIT < bit < FBIT. For example, bit = -1 rounds to an even value.
◆ roundllr()
| long long fract roundllr |
( |
long long fract |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
◆ roundlr()
| long fract roundlr |
( |
long fract |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
◆ roundr()
| fract roundr |
( |
fract |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
◆ rounduhk()
| unsigned short accum rounduhk |
( |
unsigned short accum |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
As an extension, bit may be in the range -IBIT < bit < FBIT. For example, bit = -1 rounds to an even value.
◆ rounduhr()
| unsigned short fract rounduhr |
( |
unsigned short fract |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
◆ rounduk()
| unsigned accum rounduk |
( |
unsigned accum |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
As an extension, bit may be in the range -IBIT < bit < FBIT. For example, bit = -1 rounds to an even value.
◆ roundulk()
| unsigned long accum roundulk |
( |
unsigned long accum |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
As an extension, bit may be in the range -IBIT < bit < FBIT. For example, bit = -1 rounds to an even value.
◆ roundullk()
| unsigned long long accum roundullk |
( |
unsigned long long accum |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
As an extension, bit may be in the range -IBIT < bit < FBIT. For example, bit = -1 rounds to an even value.
◆ roundullr()
| unsigned long long fract roundullr |
( |
unsigned long long fract |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
◆ roundulr()
| unsigned long fract roundulr |
( |
unsigned long fract |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
◆ roundur()
| unsigned fract roundur |
( |
unsigned fract |
val, |
|
|
int |
bit |
|
) |
| |
Round val to bit fractional bits. When the result does not fit into the range of the return type, the result is saturated.
◆ rtoa()
| char * rtoa |
( |
fract |
x, |
|
|
char * |
buf, |
|
|
unsigned char |
mode |
|
) |
| |
Convert fixed-point value x to a decimal ASCII representation. The result is written to buf, and the user is responsible for providing enough memory in buf. Returns buf.
For the meaning of mode, and for the (maximal) number of character written by this function, see uktoa().
- Since
- AVR-LibC v2.3
◆ sinpi2k()
| accum sinpi2k |
( |
accum |
deg | ) |
|
Sine of
x·π/2
radians.
The absolute error is bounded by
4.6·10−5 ≈ 2−14.4.
The worst case execution time (WCET) is around 300 cycles when MUL is available, and around 1400 cycles when MUL is not available.
- Since
- AVR-LibC v2.3
◆ sinpi2ur()
| unsigned fract sinpi2ur |
( |
unsigned fract |
x | ) |
|
Sine of
x·π/2
redians. The returned value is in the range [0, 1).
The absolute error is bounded by
2.9·10−5 ≈ 2−15.
The worst case execution time (WCET) is around 260 cycles when MUL is available, and around 1400 cycles when MUL is not available.
- Since
- AVR-LibC v2.3
◆ sinuhk_deg()
| fract sinuhk_deg |
( |
unsigned short accum |
deg | ) |
|
Sine of the angle deg where deg is specified in degrees, i.e. in the range
[0°, 256°).
The returned value is in the range (-1, +1), i.e. is never -1.
The absolute error is bounded by
6.5·10−5 ≈ 2−13.9.
The worst case execution time (WCET) is around 70 cycles.
- Since
- AVR-LibC v2.3
◆ sqrthk()
| short accum sqrthk |
( |
short accum |
radic | ) |
|
Square root of the value radic. Negative values are returned unchanged. The worst case execution time (WCET) is around 310 cycles.
- Since
- AVR-LibC v2.3
◆ sqrthr()
| short fract sqrthr |
( |
short fract |
radic | ) |
|
Square root of the value radic rounded down.
- Since
- AVR-LibC v2.3
◆ sqrtk()
| accum sqrtk |
( |
accum |
radic | ) |
|
Square root of the value radic. Negative values are returned unchanged. The worst case execution time (WCET) is around 640 cycles.
- Since
- AVR-LibC v2.3
◆ sqrtlr()
| long fract sqrtlr |
( |
long fract |
radic | ) |
|
Square root of the value radic. Negative values are returned unchanged. The worst case execution time (WCET) is around 1080 cycles.
- Since
- AVR-LibC v2.3
◆ sqrtr()
| fract sqrtr |
( |
fract |
radic | ) |
|
Square root of the value radic. Negative values are returned unchanged. The worst case execution time (WCET) is around 320 cycles.
- Since
- AVR-LibC v2.3
◆ sqrtuhk()
| unsigned short accum sqrtuhk |
( |
unsigned short accum |
radic | ) |
|
Square root of the value radic rounded down. The worst case execution time (WCET) is around 300 cycles.
- Since
- AVR-LibC v2.3
◆ sqrtuhr()
| unsigned short fract sqrtuhr |
( |
unsigned short fract |
radic | ) |
|
Square root of the value radic rounded down. The result is in the range [0, 1).
The absolute error is in the range
[−3.9·10−3 ≈ 2−8, 0].
The worst case execution time (WCET) is around 120 cycles.
- Since
- AVR-LibC v2.3
◆ sqrtuk()
| unsigned accum sqrtuk |
( |
unsigned accum |
radic | ) |
|
Square root of the value radic. The worst case execution time (WCET) is around 620 cycles.
- Since
- AVR-LibC v2.3
◆ sqrtulr()
| unsigned long fract sqrtulr |
( |
unsigned long fract |
radic | ) |
|
Square root of the value radic. The result is in the range [0, 1). The worst case execution time (WCET) is around 1060 cycles.
- Since
- AVR-LibC v2.3
◆ sqrtur()
| unsigned fract sqrtur |
( |
unsigned fract |
radic | ) |
|
Square root of the value radic. The result is in the range [0, 1).
The absolute error is in the range
[−1.5·10−5 ≈ 2−16, 0].
The worst case execution time (WCET) is around 320 cycles.
- Since
- AVR-LibC v2.3
◆ uhkbits()
| unsigned short accum uhkbits |
( |
unsigned int |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ uhktoa()
| char * uhktoa |
( |
unsigned short accum |
x, |
|
|
char * |
buf, |
|
|
unsigned char |
mode |
|
) |
| |
Convert fixed-point value x to a decimal ASCII representation. The result is written to buf, and the user is responsible for providing enough memory in buf. Returns buf.
For the meaning of mode, and for the (maximal) number of character written by this function, see uktoa().
- Since
- AVR-LibC v2.3
◆ uhrbits()
| unsigned short fract uhrbits |
( |
unsigned char |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ uhrtoa()
| char * uhrtoa |
( |
unsigned short fract |
x, |
|
|
char * |
buf, |
|
|
unsigned char |
mode |
|
) |
| |
Convert fixed-point value x to a decimal ASCII representation. The result is written to buf, and the user is responsible for providing enough memory in buf. Returns buf.
For the meaning of mode, and for the (maximal) number of character written by this function, see uktoa().
- Since
- AVR-LibC v2.3
◆ ukbits()
| unsigned accum ukbits |
( |
unsigned long |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ uktoa()
| char * uktoa |
( |
unsigned accum |
x, |
|
|
char * |
buf, |
|
|
unsigned char |
mode |
|
) |
| |
Convert fixed-point value x to a decimal ASCII representation. The result is written to buf, and the user is responsible for providing enough memory in buf. Returns buf.
The format of the output is controlled by the mode parameter. It is composed from the format flags below together with Digs, the number of fractional digits. The mode is the ORed result from Digs and a combination of FXTOA_ALL, FXTOA_ROUND or FXTOA_TRUNC, FXTOA_DOT or FXTOA_COMMA, and FXTOA_NTZ, like in:
char * uktoa(unsigned accum x, char *buf, unsigned char mode)
#define FXTOA_NTZ
Definition: stdfix-avrlibc.h:146
#define FXTOA_ROUND
Definition: stdfix-avrlibc.h:128
- Supported values for Digs are in the range 0...30.
- FXTOA_ALL
Include all significant digits. Digs will be ignored.
- FXTOA_ROUND
Round to nearest for Digs fractional digits. Rounding for Digs ≥ 5 has no effect, i.e. for such Digs values the rounded result will be the same like the truncated result. Rounding mode is the default, i.e. FXTOA_ROUND can be omitted.
- FXTOA_TRUNC
Like FXTOA_ALL, but truncate the result (round to zero) after Digs fractional digits.
- FXTOA_NTZ
- • With FXTOA_NTZ the result has no trailing zeros. When the result represents an integral value, then no decimal point and no fractional digits are present.
• Without FXTOA_NTZ and with FXTOA_ROUND or FXTOA_TRUNC, the result has the specified number of fractional digits.
• FXTOA_NTZ has no effect with FXTOA_ALL.
• FXTOA_NTZ has no effect on the required buffer size.
- FXTOA_DOT
The decimal point is a dot (.). This is the default, i.e. FXTOA_DOT can be omitted.
- FXTOA_COMMA
- The decimal point is a comma (
,).
Examples
| Value | Mode | Result |
| 1.8uk | 0 | "2" |
| 1.8uk | 1 | "1.8" |
| 1.8uk | 2 | "1.80" |
| 1.8uk | 3 | "1.800" |
| 1.8uk | FXTOA_NTZ | 0 | "2" |
| 1.8uk | FXTOA_NTZ | 1 | "1.8" |
| 1.8uk | FXTOA_NTZ | 2 | "1.8" |
| 1.8uk | FXTOA_NTZ | 3 | "1.8" |
| 1.8uk | FXTOA_TRUNC | FXTOA_COMMA | 0 | "1" |
| 1.8uk | FXTOA_TRUNC | FXTOA_COMMA | 1 | "1,7" |
| 1.8uk | FXTOA_TRUNC | FXTOA_COMMA | 2 | "1,79" |
| 1.8uk | FXTOA_TRUNC | FXTOA_COMMA | 3 | "1,799" |
| 1.8uk | FXTOA_ALL | "1.79998779296875" |
The following table helps with providing enough memory in buf.
Notice that the required size of buf is independent of FXTOA_NTZ. This is the case since with FXTOA_NTZ the required buffer size may be larger that the size of the returned string.
Maximum Number of Bytes written to buf
| Type | Function | FXTOA_ALL | All other Modes | Exact Maximal Value |
unsigned accum | uktoa | 23 | 7 + Digs | 216-2-16 | 65535.9999847412109375 |
accum | ktoa | 23 | 8 + Digs | 216-2-15 | 65535.999969482421875 |
unsigned short accum | uhktoa | 13 | 5 + Digs | 28-2-8 | 255.99609375 |
short accum | hktoa | 13 | 6 + Digs | 28-2-7 | 255.9921875 |
unsigned fract | urtoa | 19 | 3 + Digs | 1-2-16 | 0.9999847412109375 |
fract | rtoa | 19 | 4 + Digs | 1-2-15 | 0.999969482421875 |
unsigned short fract | uhrtoa | 11 | 3 + Digs | 1-2-8 | 0.99609375 |
short fract | hrtoa | 11 | 4 + Digs | 1-2-7 | 0.9921875 |
- Since
- AVR-LibC v2.3
◆ ulkbits()
| unsigned long accum ulkbits |
( |
unsigned long long |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ ullkbits()
| unsigned long long accum ullkbits |
( |
unsigned long long |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ ullrbits()
| unsigned long long fract ullrbits |
( |
unsigned long long |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ ulrbits()
| unsigned long fract ulrbits |
( |
unsigned long |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ ulrdivi()
| unsigned long fract ulrdivi |
( |
unsigned long int |
num, |
|
|
unsigned long int |
denom |
|
) |
| |
The ulrdivi() function computes the value of num/denom and returns the result of the unsigned long fract type. The return value is rounded towards zero, and is saturated on overflow. If denom is zero, the behavior is undefined.
- Since
- AVR-LibC v2.3
◆ urbits()
| unsigned fract urbits |
( |
unsigned int |
val | ) |
|
Return a fixed-point value of the same size and signedness, and with the same bit representation like val.
◆ urdivi()
| unsigned fract urdivi |
( |
unsigned int |
num, |
|
|
unsigned int |
denom |
|
) |
| |
The urdivi() function computes the value num/denom and returns the result of the unsigned fract type. The return value is rounded towards zero, and is saturated on overflow. If denom is zero, the behavior is undefined.
- Since
- AVR-LibC v2.3
◆ urtoa()
| char * urtoa |
( |
unsigned fract |
x, |
|
|
char * |
buf, |
|
|
unsigned char |
mode |
|
) |
| |
Convert fixed-point value x to a decimal ASCII representation. The result is written to buf, and the user is responsible for providing enough memory in buf. Returns buf.
For the meaning of mode, and for the (maximal) number of character written by this function, see uktoa().
- Since
- AVR-LibC v2.3