Skip to content

Commit 38093d7

Browse files
committed
fixup #8538 -- correct rounding modes for floor, trunc
This fixes the rounding modes used for the floor and trunc C library functions.
1 parent 0fc8a49 commit 38093d7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/ansi-c/library/math.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ long double ceill(long double x)
13221322

13231323
double floor(double x)
13241324
{
1325-
return __CPROVER_round_to_integrald(x, 3); // FE_DOWNWARD
1325+
return __CPROVER_round_to_integrald(x, 1); // FE_DOWNWARD
13261326
}
13271327

13281328
/* FUNCTION: floorf */
@@ -1339,7 +1339,7 @@ double floor(double x)
13391339

13401340
float floorf(float x)
13411341
{
1342-
return __CPROVER_round_to_integralf(x, 3); // FE_DOWNWARD
1342+
return __CPROVER_round_to_integralf(x, 1); // FE_DOWNWARD
13431343
}
13441344

13451345

@@ -1357,7 +1357,7 @@ float floorf(float x)
13571357

13581358
long double floorl(long double x)
13591359
{
1360-
return __CPROVER_round_to_integralld(x, 3); // FE_DOWNWARD
1360+
return __CPROVER_round_to_integralld(x, 1); // FE_DOWNWARD
13611361
}
13621362

13631363

@@ -1381,7 +1381,7 @@ long double floorl(long double x)
13811381

13821382
double trunc(double x)
13831383
{
1384-
return __CPROVER_round_to_integrald(x, 0); // FE_TOWARDZERO
1384+
return __CPROVER_round_to_integrald(x, 3); // FE_TOWARDZERO
13851385
}
13861386

13871387
/* FUNCTION: truncf */
@@ -1398,7 +1398,7 @@ double trunc(double x)
13981398

13991399
float truncf(float x)
14001400
{
1401-
return __CPROVER_round_to_integralf(x, 0); // FE_TOWARDZERO
1401+
return __CPROVER_round_to_integralf(x, 3); // FE_TOWARDZERO
14021402
}
14031403

14041404

@@ -1416,7 +1416,7 @@ float truncf(float x)
14161416

14171417
long double truncl(long double x)
14181418
{
1419-
return __CPROVER_round_to_integralld(x, 0); // FE_TOWARDZERO
1419+
return __CPROVER_round_to_integralld(x, 3); // FE_TOWARDZERO
14201420
}
14211421

14221422

@@ -1889,7 +1889,7 @@ long long int llroundl(long double x)
18891889

18901890
double modf(double x, double *iptr)
18911891
{
1892-
*iptr = __CPROVER_round_to_integrald(x, 0); // FE_TOWARDZERO
1892+
*iptr = __CPROVER_round_to_integrald(x, 3); // FE_TOWARDZERO
18931893
return (x - *iptr);
18941894
}
18951895

@@ -1907,7 +1907,7 @@ double modf(double x, double *iptr)
19071907

19081908
float modff(float x, float *iptr)
19091909
{
1910-
*iptr = __CPROVER_round_to_integralf(x, 0); // FE_TOWARDZERO
1910+
*iptr = __CPROVER_round_to_integralf(x, 3); // FE_TOWARDZERO
19111911
return (x - *iptr);
19121912
}
19131913

@@ -1926,7 +1926,7 @@ float modff(float x, float *iptr)
19261926

19271927
long double modfl(long double x, long double *iptr)
19281928
{
1929-
*iptr = __CPROVER_round_to_integralld(x, 0); // FE_TOWARDZERO
1929+
*iptr = __CPROVER_round_to_integralld(x, 3); // FE_TOWARDZERO
19301930
return (x - *iptr);
19311931
}
19321932

0 commit comments

Comments
 (0)