Commit 51901aeb authored by Julien Girard-Satabin's avatar Julien Girard-Satabin
Browse files

fixed a bug in string representation that led to overflow with Z

parent 9933e40d
module IR = Ir.Nier_cfg
(* Helper function to work with Z *)
let rec trunc_to_int32 x =
if Z.numbits x > 31 then(
trunc_to_int32 (Z.div x (Z.of_int 2))
)
else
Z.to_int x
type theory = Real_Theory | Float_Theory | Linear_Real_Theory
exception NotSupposedToHappen of string
......@@ -26,12 +34,12 @@ let float_of_string_accurate f t=
| Real_Theory | Linear_Real_Theory -> let q = Q.of_float f in
let num = Q.num q and denum = Q.den q in
let str_num =
if (Z.to_int num) < 0 then
if (trunc_to_int32 num) < 0 then
"( - "^(List.nth (String.split_on_char '-' (Z.to_string num)) 1)^")"
else
Z.to_string num
and str_denum =
if (Z.to_int denum) < 0 then
if (trunc_to_int32 denum) < 0 then
"( - "^(List.nth (String.split_on_char '-' (Z.to_string denum)) 1)^")"
else
Z.to_string denum
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment