-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce floatbv_round_to_integral_exprt
This adds a new expression, floatbv_round_to_integral, which rounds an IEEE 754 floating-point number given as bit-vector to the nearest integer, considering the explicitly given rounding mode.
- Loading branch information
Showing
24 changed files
with
627 additions
and
341 deletions.
There are no files selected for viewing
9 changes: 0 additions & 9 deletions
9
regression/cbmc-library/__sort_of_CPROVER_round_to_integral-01/main.c
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
regression/cbmc-library/__sort_of_CPROVER_round_to_integral-01/test.desc
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
regression/cbmc-library/__sort_of_CPROVER_round_to_integralf-01/main.c
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
regression/cbmc-library/__sort_of_CPROVER_round_to_integralf-01/test.desc
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
regression/cbmc-library/__sort_of_CPROVER_round_to_integrall-01/main.c
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
regression/cbmc-library/__sort_of_CPROVER_round_to_integrall-01/test.desc
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
(set-logic FP) | ||
|
||
(define-fun zero () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 0)) | ||
(define-fun minus-zero () (_ FloatingPoint 11 53) (fp.neg zero)) | ||
(define-fun one () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 1)) | ||
(define-fun minus-one () (_ FloatingPoint 11 53) (fp.neg one)) | ||
(define-fun zero-point-one () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 0.1)) | ||
(define-fun minus-zero-point-one () (_ FloatingPoint 11 53) (fp.neg zero-point-one)) | ||
(define-fun ten-point-one () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 10.1)) | ||
(define-fun minus-ten-point-one () (_ FloatingPoint 11 53) (fp.neg ten-point-one)) | ||
(define-fun ten () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 10)) | ||
(define-fun minus-ten () (_ FloatingPoint 11 53) (fp.neg ten)) | ||
(define-fun eleven () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 11)) | ||
(define-fun minus-eleven () (_ FloatingPoint 11 53) (fp.neg eleven)) | ||
(define-fun magic () (_ FloatingPoint 11 53) (fp #b0 #b10000110011 #x0000000000000)) | ||
(define-fun dmax () (_ FloatingPoint 11 53) (fp #b0 #b11111111110 #xFFFFFFFFFFFFF)) | ||
|
||
(assert (not (and | ||
|
||
; round up | ||
(= (fp.roundToIntegral RTP (_ NaN 11 53)) (_ NaN 11 53)) | ||
(= (fp.roundToIntegral RTP (_ +oo 11 53)) (_ +oo 11 53)) | ||
(= (fp.roundToIntegral RTP (_ -oo 11 53)) (_ -oo 11 53)) | ||
(= (fp.roundToIntegral RTP zero) zero) | ||
(= (fp.roundToIntegral RTP minus-zero) minus-zero) | ||
(= (fp.roundToIntegral RTP one) one) | ||
(= (fp.roundToIntegral RTP zero-point-one) one) | ||
(= (fp.roundToIntegral RTP minus-zero-point-one) minus-zero) | ||
(= (fp.roundToIntegral RTP ten-point-one) eleven) | ||
(= (fp.roundToIntegral RTP minus-ten-point-one) minus-ten) | ||
(= (fp.roundToIntegral RTP magic) magic) | ||
(= (fp.roundToIntegral RTP dmax) dmax) | ||
|
||
; round down | ||
(= (fp.roundToIntegral RTN (_ NaN 11 53)) (_ NaN 11 53)) | ||
(= (fp.roundToIntegral RTN (_ +oo 11 53)) (_ +oo 11 53)) | ||
(= (fp.roundToIntegral RTN (_ -oo 11 53)) (_ -oo 11 53)) | ||
(= (fp.roundToIntegral RTN zero) zero) | ||
(= (fp.roundToIntegral RTN minus-zero) minus-zero) | ||
(= (fp.roundToIntegral RTN one) one) | ||
(= (fp.roundToIntegral RTN zero-point-one) zero) | ||
(= (fp.roundToIntegral RTN minus-zero-point-one) minus-one) | ||
(= (fp.roundToIntegral RTN ten-point-one) ten) | ||
(= (fp.roundToIntegral RTN minus-ten-point-one) minus-eleven) | ||
(= (fp.roundToIntegral RTN magic) magic) | ||
(= (fp.roundToIntegral RTN dmax) dmax) | ||
|
||
; round to nearest ties to even | ||
(= (fp.roundToIntegral RNE (_ NaN 11 53)) (_ NaN 11 53)) | ||
(= (fp.roundToIntegral RNE (_ +oo 11 53)) (_ +oo 11 53)) | ||
(= (fp.roundToIntegral RNE (_ -oo 11 53)) (_ -oo 11 53)) | ||
(= (fp.roundToIntegral RNE zero) zero) | ||
(= (fp.roundToIntegral RNE minus-zero) minus-zero) | ||
(= (fp.roundToIntegral RNE one) one) | ||
(= (fp.roundToIntegral RNE zero-point-one) zero) | ||
(= (fp.roundToIntegral RNE minus-zero-point-one) minus-zero) | ||
(= (fp.roundToIntegral RNE ten-point-one) ten) | ||
(= (fp.roundToIntegral RNE minus-ten-point-one) minus-ten) | ||
(= (fp.roundToIntegral RNE magic) magic) | ||
(= (fp.roundToIntegral RNE dmax) dmax) | ||
|
||
; round to zero | ||
(= (fp.roundToIntegral RTZ (_ NaN 11 53)) (_ NaN 11 53)) | ||
(= (fp.roundToIntegral RTZ (_ +oo 11 53)) (_ +oo 11 53)) | ||
(= (fp.roundToIntegral RTZ (_ -oo 11 53)) (_ -oo 11 53)) | ||
(= (fp.roundToIntegral RTZ zero) zero) | ||
(= (fp.roundToIntegral RTZ minus-zero) minus-zero) | ||
(= (fp.roundToIntegral RTZ one) one) | ||
(= (fp.roundToIntegral RTZ zero-point-one) zero) | ||
(= (fp.roundToIntegral RTZ minus-zero-point-one) minus-zero) | ||
(= (fp.roundToIntegral RTZ ten-point-one) ten) | ||
(= (fp.roundToIntegral RTZ minus-ten-point-one) minus-ten) | ||
(= (fp.roundToIntegral RTZ magic) magic) | ||
(= (fp.roundToIntegral RTZ dmax) dmax) | ||
))) | ||
|
||
; should be unsat | ||
(check-sat) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.