2020-06-15 14:18:57 +00:00
|
|
|
|
#ifndef COSMOPOLITAN_LIBC_TINYMATH_EMOD_H_
|
|
|
|
|
#define COSMOPOLITAN_LIBC_TINYMATH_EMOD_H_
|
|
|
|
|
#include "libc/math.h"
|
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns Euclidean floating-point division remainder.
|
|
|
|
|
*
|
|
|
|
|
* @return (𝑥 mod 𝑦) ∈ [0.,𝑦)
|
|
|
|
|
* @see fmod()
|
|
|
|
|
*/
|
2020-12-01 11:43:40 +00:00
|
|
|
|
static inline double emod(double x, double y) {
|
2020-06-15 14:18:57 +00:00
|
|
|
|
return x - fabs(y) * floor(x / fabs(y));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_TINYMATH_EMOD_H_ */
|