2020-06-15 14:18:57 +00:00
|
|
|
#ifndef COSMOPOLITAN_DSP_CORE_ITUROUND_H_
|
|
|
|
#define COSMOPOLITAN_DSP_CORE_ITUROUND_H_
|
|
|
|
#include "libc/math.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An ITU recommended rounding function.
|
|
|
|
*
|
|
|
|
* 1. Negative numbers round toward zero
|
|
|
|
* 2. Positive numbers round toward infinity
|
|
|
|
*
|
|
|
|
* @see round(), rint()
|
|
|
|
*/
|
2023-06-09 13:41:34 +00:00
|
|
|
__funline long ituround(double x) {
|
2020-06-15 14:18:57 +00:00
|
|
|
return floor(x + .5);
|
|
|
|
}
|
|
|
|
|
2023-06-09 13:41:34 +00:00
|
|
|
__funline int ituroundf(float x) {
|
2020-06-15 14:18:57 +00:00
|
|
|
return floorf(x + .5f);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* COSMOPOLITAN_DSP_CORE_ITUROUND_H_ */
|