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: | Dmitry Bely <dmitry.bely@g...> |
| Subject: | Re: [Caml-list] Re: Question about float refs. |
On Tue, Aug 31, 2010 at 11:41 PM, Jon Harrop <jonathandeanharrop@googlemail.com> wrote: > 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) Do you have any idea why the optimizer needs that? - Dmitry Bely