Browse thread
Question about float refs.
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jon Harrop <jonathandeanharrop@g...> |
| Subject: | RE: [Caml-list] Re: Question about float refs. |
You might prefer to multiply by 1.0 because adding 0.0 changes -0.0. Cheers, Jon. > Some black magic is needed: > > let r = ref 0.0 in > for i = 0 to 1000_000_000 do r := float i done; > Printf.printf "%f\n" (!r +. 0.); > Printf.printf "words: %f\n" (Gc.stat ()).Gc.minor_words > > and the reference will be placed in a register (Caml heap will not be > used inside the loop) > > - Dmitry Bely