Skip to content

Commit 2c2733f

Browse files
committed
Cleanup fmod vs IEEE remainder
1. Add tests for both the C and Java front-end. 2. Make sure we support both variants of the modulus operator on floating-point values in the back-ends: the SMT back-end only supported remainder (and only for FPA mode), the propositional back-end did not distinguish between fmod and IEEE remainder.
1 parent 55a26d4 commit 2c2733f

File tree

30 files changed

+203
-212
lines changed

30 files changed

+203
-212
lines changed
884 Bytes
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class farith2
2+
{
3+
public static void main(String[] args)
4+
{
5+
// examples from
6+
// https://stackoverflow.com/questions/2947044/how-do-i-use-modulus-for-float-double
7+
// and
8+
// https://stackoverflow.com/questions/25734144/difference-between-c-functions-remainder-and-fmod
9+
double d1 = 0.5 % 0.3;
10+
assert d1 == 0.2;
11+
double d2 = (-0.5) % 0.3;
12+
assert d2 == -0.2;
13+
double x = 7.5, y = 2.1;
14+
double xModY = x % y;
15+
assert xModY > 1.19 && xModY < 1.21;
16+
}
17+
}

regression/cbmc-library/__sort_of_CPROVER_remainder-01/test.desc renamed to jbmc/regression/jbmc/farith2/test.desc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
KNOWNBUG
2-
main.c
3-
--pointer-check --bounds-check
1+
CORE
2+
farith2
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

regression/cbmc-library/__sort_of_CPROVER_remainder-01/main.c

Lines changed: 0 additions & 9 deletions
This file was deleted.

regression/cbmc-library/__sort_of_CPROVER_remainderf-01/main.c

Lines changed: 0 additions & 9 deletions
This file was deleted.

regression/cbmc-library/__sort_of_CPROVER_remainderf-01/test.desc

Lines changed: 0 additions & 8 deletions
This file was deleted.

regression/cbmc-library/__sort_of_CPROVER_remainderl-01/main.c

Lines changed: 0 additions & 9 deletions
This file was deleted.

regression/cbmc-library/__sort_of_CPROVER_remainderl-01/test.desc

Lines changed: 0 additions & 8 deletions
This file was deleted.

regression/cbmc-library/fmod-01/main.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33

44
int main()
55
{
6-
fmod();
7-
assert(0);
8-
return 0;
6+
// examples from
7+
// https://stackoverflow.com/questions/2947044/how-do-i-use-modulus-for-float-double
8+
// and
9+
// https://stackoverflow.com/questions/25734144/difference-between-c-functions-remainder-and-fmod
10+
double d1 = fmod(0.5, 0.3);
11+
assert(d1 == 0.2);
12+
double d2 = fmod(-0.5, 0.3);
13+
assert(d2 == -0.2);
14+
double x = 7.5, y = 2.1;
15+
double xModY = fmod(x, y);
16+
assert(xModY > 1.19 && xModY < 1.21);
917
}

regression/cbmc-library/fmod-01/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
KNOWNBUG
1+
CORE
22
main.c
3-
--pointer-check --bounds-check
3+
--float-overflow-check --nan-check
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

0 commit comments

Comments
 (0)