Skip to content

Commit 42e9331

Browse files
martintautschnig
martin
authored andcommitted
Fix special cases for the remainder functions, now down to 4 failures!
1 parent cd5dd3e commit 42e9331

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/ansi-c/library/math.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ inline float __builtin_fabsf(float f) { return __CPROVER_fabsf(f); }
2424

2525
/* FUNCTION: __builtin_isgreater */
2626

27-
int __builtin_isgreater(float f, float g) { return f > g; }
27+
int __builtin_isgreater(double f, double g) { return f > g; }
2828

2929
/* FUNCTION: __builtin_isgreaterequal */
3030

@@ -40,7 +40,7 @@ int __builtin_islessequal(float f, float g) { return f <= g; }
4040

4141
/* FUNCTION: __builtin_islessgreater */
4242

43-
int __builtin_islessgreater(float f, float g) { return (f < g) || (g > f); }
43+
int __builtin_islessgreater(float f, float g) { return (f < g) || (f > g); }
4444

4545
/* FUNCTION: __builtin_isunordered */
4646

@@ -2050,6 +2050,9 @@ double __sort_of_CPROVER_round_to_integral (int rounding_mode, double d);
20502050

20512051
double __sort_of_CPROVER_remainder (int rounding_mode, double x, double y)
20522052
{
2053+
if (x == 0.0 || __CPROVER_isinfd(y))
2054+
return x;
2055+
20532056
// Extended precision helps... a bit...
20542057
long double div = x/y;
20552058
long double n = __sort_of_CPROVER_round_to_integral(rounding_mode,div);
@@ -2064,6 +2067,9 @@ float __sort_of_CPROVER_round_to_integralf (int rounding_mode, float d);
20642067

20652068
float __sort_of_CPROVER_remainderf (int rounding_mode, float x, float y)
20662069
{
2070+
if (x == 0.0f || __CPROVER_isinff(y))
2071+
return x;
2072+
20672073
// Extended precision helps... a bit...
20682074
long double div = x/y;
20692075
long double n = __sort_of_CPROVER_round_to_integral(rounding_mode,div);
@@ -2078,6 +2084,9 @@ long double __sort_of_CPROVER_round_to_integrall (int rounding_mode, long double
20782084

20792085
long double __sort_of_CPROVER_remainderl (int rounding_mode, long double x, long double y)
20802086
{
2087+
if (x == 0.0 || __CPROVER_isinfld(y))
2088+
return x;
2089+
20812090
// Extended precision helps... a bit...
20822091
long double div = x/y;
20832092
long double n = __sort_of_CPROVER_round_to_integral(rounding_mode,div);

0 commit comments

Comments
 (0)