From 128e8d23fa55fe148a96186a81efb8bad7995d29 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Wed, 1 Jun 2005 20:03:12 +0000 Subject: [PATCH] Add more missing float math (modf and modff). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12923 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/posix/math/floatmath.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/system/libroot/posix/math/floatmath.c b/src/system/libroot/posix/math/floatmath.c index 2be66787ae..60e5f9a255 100644 --- a/src/system/libroot/posix/math/floatmath.c +++ b/src/system/libroot/posix/math/floatmath.c @@ -41,3 +41,21 @@ float gammaf(float x) {return (float)gamma((double)x);}; float lgammaf(float x) {return (float)lgamma((double)x);}; float rintf(float x) {return (float)rint((double)x);}; float scalbf(float x, float n) {return (float)scalb((double)x, (double)n);}; + +// TODO: use optimized versions of these +double +modf(double x, double *y) +{ + int integer = (int)x; + *y = (double)integer; + return x - integer; +} + +float +modff(float x, float *y) +{ + double intpart = 0; + float result = (float)modf((double)x, &intpart); + *y = (float)intpart; + return result; +}