fix remainder*.c: remove useless long double cast
This commit is contained in:
parent
4caa17b2a1
commit
b03255af77
2 changed files with 6 additions and 15 deletions
|
|
@ -20,8 +20,6 @@
|
||||||
|
|
||||||
#include "libm.h"
|
#include "libm.h"
|
||||||
|
|
||||||
static const double zero = 0.0;
|
|
||||||
|
|
||||||
double remainder(double x, double p)
|
double remainder(double x, double p)
|
||||||
{
|
{
|
||||||
int32_t hx,hp;
|
int32_t hx,hp;
|
||||||
|
|
@ -35,17 +33,15 @@ double remainder(double x, double p)
|
||||||
hx &= 0x7fffffff;
|
hx &= 0x7fffffff;
|
||||||
|
|
||||||
/* purge off exception values */
|
/* purge off exception values */
|
||||||
if ((hp|lp) == 0) /* p = 0 */
|
if ((hp|lp) == 0 || /* p = 0 */
|
||||||
return (x*p)/(x*p);
|
hx >= 0x7ff00000 || /* x not finite */
|
||||||
if (hx >= 0x7ff00000 || /* x not finite */
|
|
||||||
(hp >= 0x7ff00000 && (hp-0x7ff00000 | lp) != 0)) /* p is NaN */
|
(hp >= 0x7ff00000 && (hp-0x7ff00000 | lp) != 0)) /* p is NaN */
|
||||||
// FIXME: why long double?
|
return (x*p)/(x*p);
|
||||||
return ((long double)x*p)/((long double)x*p);
|
|
||||||
|
|
||||||
if (hp <= 0x7fdfffff)
|
if (hp <= 0x7fdfffff)
|
||||||
x = fmod(x, p+p); /* now x < 2p */
|
x = fmod(x, p+p); /* now x < 2p */
|
||||||
if (((hx-hp)|(lx-lp)) == 0)
|
if (((hx-hp)|(lx-lp)) == 0)
|
||||||
return zero*x;
|
return 0.0*x;
|
||||||
x = fabs(x);
|
x = fabs(x);
|
||||||
p = fabs(p);
|
p = fabs(p);
|
||||||
if (hp < 0x00200000) {
|
if (hp < 0x00200000) {
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,6 @@
|
||||||
|
|
||||||
#include "libm.h"
|
#include "libm.h"
|
||||||
|
|
||||||
static const float zero = 0.0;
|
|
||||||
|
|
||||||
float remainderf(float x, float p)
|
float remainderf(float x, float p)
|
||||||
{
|
{
|
||||||
int32_t hx,hp;
|
int32_t hx,hp;
|
||||||
|
|
@ -30,16 +28,13 @@ float remainderf(float x, float p)
|
||||||
hx &= 0x7fffffff;
|
hx &= 0x7fffffff;
|
||||||
|
|
||||||
/* purge off exception values */
|
/* purge off exception values */
|
||||||
if (hp == 0) /* p = 0 */
|
if (hp == 0 || hx >= 0x7f800000 || hp > 0x7f800000) /* p = 0, x not finite, p is NaN */
|
||||||
return (x*p)/(x*p);
|
return (x*p)/(x*p);
|
||||||
if (hx >= 0x7f800000 || hp > 0x7f800000) /* x not finite, p is NaN */
|
|
||||||
// FIXME: why long double?
|
|
||||||
return ((long double)x*p)/((long double)x*p);
|
|
||||||
|
|
||||||
if (hp <= 0x7effffff)
|
if (hp <= 0x7effffff)
|
||||||
x = fmodf(x, p + p); /* now x < 2p */
|
x = fmodf(x, p + p); /* now x < 2p */
|
||||||
if (hx - hp == 0)
|
if (hx - hp == 0)
|
||||||
return zero*x;
|
return 0.0f*x;
|
||||||
x = fabsf(x);
|
x = fabsf(x);
|
||||||
p = fabsf(p);
|
p = fabsf(p);
|
||||||
if (hp < 0x01000000) {
|
if (hp < 0x01000000) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue