/* Get signed integer and fractional parts of a floating-point number.
- Copyright (C) 2012 Free Software Foundation, Inc.
+ Copyright (C) 2012-2014 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
long double
modfl (long double x, long double *iptr)
{
- long double integer_part = truncl (x);
- *iptr = integer_part;
- return x - integer_part;
+ if (isfinite (x))
+ {
+ long double integer_part = truncl (x);
+ *iptr = integer_part;
+ return x - integer_part;
+ }
+ else
+ {
+ if (isinf (x))
+ {
+ *iptr = x;
+ return 1.0L / x;
+ }
+ else /* isnanl (x) */
+ {
+ *iptr = x;
+ return x;
+ }
+ }
}
#endif