From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 9D7ACBC57 for ; Tue, 31 Aug 2010 21:41:36 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBACP4fExKfVI0kGdsb2JhbACUVot7CBUBAQEBCQkMBxEDH6Vfiz8BBY9HAQSFNw X-IronPort-AV: E=Sophos;i="4.56,300,1280700000"; d="scan'208";a="58139445" Received: from mail-ww0-f52.google.com ([74.125.82.52]) by mail2-smtp-roc.national.inria.fr with ESMTP; 31 Aug 2010 21:41:36 +0200 Received: by wwi17 with SMTP id 17so4031786wwi.9 for ; Tue, 31 Aug 2010 12:41:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:from:to:references :in-reply-to:subject:date:organization:message-id:mime-version :content-type:content-transfer-encoding:x-mailer:thread-index :content-language; bh=k7xq/M+MmMiVVLA692szQsX298Q99CfpNDNgNjaDdTE=; b=F3cEqgNVoV4tKLLAiOnTKkmOmtZOHe8mbUzPGvQnvsJMNHnWkUV/8Gw6D6GyfmQPj4 85yUvEj0s8K9IMLkuK5+IEGk8HX/TAPAdkj6OOZw06cE8xo9xLQI+0uDsGWlp5w1Vzsa MTCIkY94alEaaWNZpXGUUGqvV6dZwhbSlhZcI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:references:in-reply-to:subject:date:organization:message-id :mime-version:content-type:content-transfer-encoding:x-mailer :thread-index:content-language; b=qSNLyM2uSiuCF5LjHGw7cZCawX8eM6CfcK7GtIXhzHZEcTl+RppTP1bK6JUZ780BOu MRNRaLL956HD/V30NL0k2ojsa3BhfVCvZsf4/eOHAeG6uHXsNWf4p6XkhSmamoCXa1D4 T8LcPCUnnkFBrAQwucKRBZr5jqqc5WbqHnHt0= Received: by 10.227.147.79 with SMTP id k15mr6930621wbv.128.1283283696106; Tue, 31 Aug 2010 12:41:36 -0700 (PDT) Received: from WinEight (87.112.103.202.plusnet.ptn-ag2.dyn.plus.net [87.112.103.202]) by mx.google.com with ESMTPS id i14sm7960920wbe.0.2010.08.31.12.41.33 (version=SSLv3 cipher=RC4-MD5); Tue, 31 Aug 2010 12:41:33 -0700 (PDT) From: Jon Harrop To: "'Dmitry Bely'" , References: <20100823.140626.634675953541672216.Christophe.Troestler+ocaml@umons.ac.be> In-Reply-To: Subject: RE: [Caml-list] Re: Question about float refs. Date: Tue, 31 Aug 2010 20:41:09 +0100 Organization: Flying Frog Consultancy Message-ID: <031b01cb4944$77110900$65331b00$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: ActCwy2FNMTyzbiSR8Or2mvuKqiLIQGgTHVA Content-Language: en-gb X-Spam: no; 0.00; cheers:01 printf:01 printf:01 1.0:98 heap:01 dmitry:01 caml-list:01 minor:01 bely:01 caml:02 black:96 float:03 float:03 let:03 refs:04 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