cosmopolitan/libc/tinymath/emod.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
527 B
C
Raw Normal View History

2020-06-15 14:18:57 +00:00
#ifndef COSMOPOLITAN_LIBC_TINYMATH_EMOD_H_
#define COSMOPOLITAN_LIBC_TINYMATH_EMOD_H_
#include "libc/math.h"
/**
* Returns Euclidean floating-point division remainder.
*
* @return (𝑥 mod 𝑦) [0.,𝑦)
* @see fmod()
*/
#define emod(x, y) \
({ \
double __x = x; \
double __y = y; \
__x - fabs(__y) * floor(__x / fabs(__y)); \
})
2020-06-15 14:18:57 +00:00
#endif /* COSMOPOLITAN_LIBC_TINYMATH_EMOD_H_ */