mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Initial import
This commit is contained in:
commit
c91b3c5006
14915 changed files with 590219 additions and 0 deletions
23
dsp/core/ituround.h
Normal file
23
dsp/core/ituround.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef COSMOPOLITAN_DSP_CORE_ITUROUND_H_
|
||||
#define COSMOPOLITAN_DSP_CORE_ITUROUND_H_
|
||||
#include "libc/math.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
/**
|
||||
* An ITU recommended rounding function.
|
||||
*
|
||||
* 1. Negative numbers round toward zero
|
||||
* 2. Positive numbers round toward infinity
|
||||
*
|
||||
* @see round(), rint()
|
||||
*/
|
||||
static inline pureconst artificial long ituround(double x) {
|
||||
return floor(x + .5);
|
||||
}
|
||||
|
||||
static inline pureconst artificial int ituroundf(float x) {
|
||||
return floorf(x + .5f);
|
||||
}
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_DSP_CORE_ITUROUND_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue