Skip to content

Commit ac35262

Browse files
Fix fmod(x, INFINITY) case
The case where the second argument is +-inf was wrongly implemented by float_utils.rem.
1 parent 1d3132e commit ac35262

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

regression/cbmc/fmod1/test.desc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33

44
^EXIT=0$
@@ -7,5 +7,3 @@ main.c
77
--
88
^warning: ignoring
99
--
10-
Currently, the case where the second argument is +-inf is wrongly
11-
implemented by float_utils.rem.

src/solvers/floatbv/float_utils.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,11 @@ bvt float_utilst::rem(const bvt &src1, const bvt &src2)
547547
We have some approaches that are correct but they really
548548
don't scale. */
549549

550-
// stub: do src1-(src1/src2)*src2
551-
return sub(src1, mul(div(src1, src2), src2));
550+
const unbiased_floatt unpacked2 = unpack(src2);
551+
552+
// stub: do (src2.infinity ? src1 : (src1/src2)*src2))
553+
return bv_utils.select(
554+
unpacked2.infinity, src1, sub(src1, mul(div(src1, src2), src2)));
552555
}
553556

554557
bvt float_utilst::negate(const bvt &src)

0 commit comments

Comments
 (0)