caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Bug] Different behavior bytecode/nativecode
@ 2005-02-27  0:13 Christophe TROESTLER
  2005-02-27  2:32 ` [Caml-list] " Kurt Welgehausen
  2005-02-27  4:44 ` Jon Harrop
  0 siblings, 2 replies; 5+ messages in thread
From: Christophe TROESTLER @ 2005-02-27  0:13 UTC (permalink / raw)
  To: O'Caml Mailing List; +Cc: caml-bugs

[-- Attachment #1: Type: Text/Plain, Size: 400 bytes --]

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


[-- Attachment #2: mandelbrot.ml --]
[-- Type: Text/Plain, Size: 484 bytes --]

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);


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-02-27 11:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-27  0:13 [Bug] Different behavior bytecode/nativecode Christophe TROESTLER
2005-02-27  2:32 ` [Caml-list] " Kurt Welgehausen
2005-02-27  4:44 ` Jon Harrop
2005-02-27 10:13   ` Christophe TROESTLER
2005-02-27 11:10     ` Jon Harrop

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).