You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 3495 Reporter: administrator Status: closed Resolution: not a bug Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Bug description
Hi,
When I compile the attached program to bytecode, I get the output
"0.000000 -1.000000 -> 1" (which is correct) but when I compile to
native code the result is "0.000000 -1.000000 -> 0".
The error stops when I substitute "invw" in "let cr = 300. *. invw
-. 1.5" by its definition (i.e. if I write
"let cr = 300. *. (2. /. float w) -. 1.5").
Curious to know what is the problem.
Cheers,
ChriS
let niter = 50
let limit = 2.
let limit2 = limit *. limit
let add_bit0 cr ci byte =
let rec loop i zr zi =
if zr *. zr +. zi *. zi > limit2 then (byte lsl 1) lor 0x00
else if i > niter then (byte lsl 1) lor 0x01
else loop (i + 1) (zr *. zr -. zi *. zi +. cr) (2. *. zr *. zi +. ci) in
loop 1 0. 0.
let () =
let w = 400 in
let invw = 2. /. float w in
let ci = -1. in
let cr = 300. *. invw -. 1.5 in
Printf.printf "%f %f -> %i\n" cr ci (add_bit0 cr ci 0);
The text was updated successfully, but these errors were encountered:
Original bug ID: 3495
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Hi,
When I compile the attached program to bytecode, I get the output
"0.000000 -1.000000 -> 1" (which is correct) but when I compile to
native code the result is "0.000000 -1.000000 -> 0".
The error stops when I substitute "invw" in "let cr = 300. *. invw
-. 1.5" by its definition (i.e. if I write
"let cr = 300. *. (2. /. float w) -. 1.5").
Curious to know what is the problem.
Cheers,
ChriS
let niter = 50
let limit = 2.
let limit2 = limit *. limit
let add_bit0 cr ci byte =
let rec loop i zr zi =
if zr *. zr +. zi *. zi > limit2 then (byte lsl 1) lor 0x00
else if i > niter then (byte lsl 1) lor 0x01
else loop (i + 1) (zr *. zr -. zi *. zi +. cr) (2. *. zr *. zi +. ci) in
loop 1 0. 0.
let () =
let w = 400 in
let invw = 2. /. float w in
let ci = -1. in
let cr = 300. *. invw -. 1.5 in
Printf.printf "%f %f -> %i\n" cr ci (add_bit0 cr ci 0);
The text was updated successfully, but these errors were encountered: