Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
119
Issues
119
List
Boards
Labels
Service Desk
Milestones
Merge Requests
16
Merge Requests
16
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
bce5bafe
Commit
bce5bafe
authored
Aug 22, 2019
by
Sylvain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
why3execute: Fix subnormalize rounding, equality, and inversion
parent
9bc2021b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
src/mlw/big_real.ml
src/mlw/big_real.ml
+11
-9
src/mlw/pinterp.ml
src/mlw/pinterp.ml
+4
-5
No files found.
src/mlw/big_real.ml
View file @
bce5bafe
...
...
@@ -75,12 +75,9 @@ let inv (xmin, xmax) =
raise
Undetermined
else
let
one
=
get_one
()
in
let
inv1_min
=
div
~
prec
~
rnd
:
Toward_Minus_Infinity
one
xmin
in
let
inv2_min
=
div
~
prec
~
rnd
:
Toward_Minus_Infinity
one
xmax
in
let
res_min
=
min
~
prec
~
rnd
:
Toward_Minus_Infinity
inv1_min
inv2_min
in
let
inv1_max
=
div
~
prec
~
rnd
:
Toward_Plus_Infinity
one
xmin
in
let
inv2_max
=
div
~
prec
~
rnd
:
Toward_Plus_Infinity
one
xmax
in
let
res_max
=
max
~
prec
~
rnd
:
Toward_Plus_Infinity
inv1_max
inv2_max
in
(* Inverse is decreasing on ]-inf; 0[ and on ]0; inf[ *)
let
res_min
=
div
~
prec
~
rnd
:
Toward_Minus_Infinity
one
xmax
in
let
res_max
=
div
~
prec
~
rnd
:
Toward_Plus_Infinity
one
xmin
in
(
res_min
,
res_max
)
let
div
x
y
=
...
...
@@ -109,10 +106,15 @@ let real_from_fraction p q =
div
p
q
let
eq
(
xmin
,
xmax
)
(
ymin
,
ymax
)
=
if
(
equal_p
xmin
xmax
)
&&
(
equal_p
ymin
ymax
)
then
equal_p
xmin
ymin
if
less_p
ymax
xmin
||
less_p
xmax
ymin
then
(* Intervals are disjoint *)
false
else
raise
Undetermined
if
(
equal_p
xmin
xmax
)
&&
(
equal_p
ymin
ymax
)
then
(* Intervals are singleton and not disjoint, hence are equal *)
true
else
raise
Undetermined
let
lt
(
x1
,
x2
)
(
y1
,
y2
)
=
if
less_p
x2
y1
then
true
else
...
...
src/mlw/pinterp.ml
View file @
bce5bafe
...
...
@@ -230,18 +230,17 @@ let use_fmode (fmode: int) =
let
eval_float
:
type
a
.
int
->
a
float_arity
->
a
->
Expr
.
rsymbol
->
value
list
->
value
=
(
fun
fmode
ty
op
ls
l
->
(* Simulate IEEE behavior *)
let
subnormalize
=
subnormalize
~
rnd
:
To_Nearest
in
(* Set the exponent depending on Float type that are used: 32 or 64 *)
use_fmode
fmode
;
try
begin
match
ty
,
l
with
|
Mode1
,
[
Vfloat_mode
mode
;
Vfloat
f
]
->
Vfloat
(
subnormalize
(
op
mode
f
))
(* Subnormalize used to simulate IEEE behavior *)
Vfloat
(
subnormalize
~
rnd
:
mode
(
op
mode
f
))
|
Mode2
,
[
Vfloat_mode
mode
;
Vfloat
f1
;
Vfloat
f2
]
->
Vfloat
(
subnormalize
(
op
mode
f1
f2
))
Vfloat
(
subnormalize
~
rnd
:
mode
(
op
mode
f1
f2
))
|
Mode3
,
[
Vfloat_mode
mode
;
Vfloat
f1
;
Vfloat
f2
;
Vfloat
f3
]
->
Vfloat
(
subnormalize
(
op
mode
f1
f2
f3
))
Vfloat
(
subnormalize
~
rnd
:
mode
(
op
mode
f1
f2
f3
))
|
Mode_rel
,
[
Vfloat
f1
;
Vfloat
f2
]
->
Vbool
(
op
f1
f2
)
|
Mode_rel1
,
[
Vfloat
f
]
->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment