Macros | Functions
Math.h File Reference

Detailed Description

Math utility functions.

#include <stdint.h>
Include dependency graph for Math.h:

Go to the source code of this file.

Macros

#define Math_MIN(x, y)   (((x) < (y)) ? (x) : (y))
 Macro to determine the minimum of two numbers. More...
 
#define Math_MAX(x, y)   (((x) > (y)) ? (x) : (y))
 Macro to determine the maximum of two numbers. More...
 
#define Math_ABS(x)   ((x) < 0 ? -(x) : (x))
 Macro to calculate the absolute value of a numbers. More...
 

Functions

uint32_t Math_divideBy1000 (uint32_t dividend)
 Divide a number by 1000. More...
 

Macro Definition Documentation

§ Math_MIN

#define Math_MIN (   x,
 
)    (((x) < (y)) ? (x) : (y))

Macro to determine the minimum of two numbers.

Warning
Do not use arguments that have a side effect. For example do not use pre- and post-increment operators.
Parameters
xThe first number. Either an integer or a floating point type.
yThe second number. Must be the same type as x.
Returns
The minimum of x and y

§ Math_MAX

#define Math_MAX (   x,
 
)    (((x) > (y)) ? (x) : (y))

Macro to determine the maximum of two numbers.

Warning
Do not use arguments that have a side effect. For example do not use pre- and post-increment operators.
Parameters
xThe first number. Either an integer or a floating point type.
yThe second number. Must be the same type as x.
Returns
The maximum of x and y

§ Math_ABS

#define Math_ABS (   x)    ((x) < 0 ? -(x) : (x))

Macro to calculate the absolute value of a numbers.

Warning
Do not use arguments that have a side effect. For example do not use pre- and post-increment operators.
Parameters
xThe number to calculate the absolute value of. Either a signed integer or a floating point type.
Returns
The absolute value of x

Function Documentation

§ Math_divideBy1000()

uint32_t Math_divideBy1000 ( uint32_t  dividend)

Divide a number by 1000.

This function is intended for devices without a hardware divider (for example CC23X0) that must run divisions (that are not a power of 2) in software. The generic software division implementations provided by compilers are relatively slow. This function only supports dividing by 1000, but does so in ~16 cycles vs. ~95 cycles for the generic implementations.

Warning
Limitations: The division is only accurate for dividend < 754515999, and off by 1 for values of dividend = 754515999 + 1000*n.
Parameters
dividendThe dividend to be divided by 1000. Must be below 754515999 for division to be accurate.
Returns
Returns dividend / 1000 (see limitations)
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale