From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E922EBC0A for ; Fri, 16 Feb 2007 23:26:35 +0100 (CET) Received: from mail15.bluewin.ch (mail15.bluewin.ch [195.186.18.63]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1GMQZfh008498 for ; Fri, 16 Feb 2007 23:26:35 +0100 Received: from [10.0.1.2] (85.2.30.249) by mail15.bluewin.ch (Bluewin 7.3.121) id 45C31B2B003EE2CD; Fri, 16 Feb 2007 22:26:35 +0000 In-Reply-To: <45D603A4.7080500@laposte.net> References: <45D5C3AD.2000606@laposte.net> <98085E4A-B42B-4570-90DC-842ABA89F5D6@epfl.ch> <45D5D9DC.8050704@laposte.net> <16855695-F439-47FB-80D1-171CD88833C2@epfl.ch> <45D603A4.7080500@laposte.net> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed Message-Id: <094AF8BA-F1B1-4C06-B9AF-E215842649A5@epfl.ch> Cc: Caml List Content-Transfer-Encoding: quoted-printable From: =?ISO-8859-1?Q?Daniel_B=FCnzli?= Subject: Re: [Caml-list] CAMLreturn does not work for floats between 0 and 1 ? Date: Fri, 16 Feb 2007 23:28:21 +0100 To: matthieu.dubuget@laposte.net X-Mailer: Apple Mail (2.752.2) X-Miltered: at concorde with ID 45D62F9B.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bunzli:01 buenzli:01 camlreturn:01 matthieu:01 dubuget:01 camlreturn:01 ocaml:01 runtime:01 unboxed:01 pointer:01 alloc:01 pointer:01 malloc:01 runtime:01 misused:98 Le 16 f=E9vr. 07 =E0 20:19, Matthieu Dubuget a =E9crit : > At the first place, except the fact that I misused the macros, I still > do not understand why CAMLreturn(0.05) would return 0.? Because CAMLreturn assumes its parameter is a value of the C type =20 'value' which represent a value of the ocaml runtime system and can =20 be either (from the doc) : > an unboxed integer; > a pointer to a block inside the heap (such as the blocks allocated =20 > through one of the caml_alloc_* functions below); > a pointer to an object outside the heap (e.g., a pointer to a block =20= > allocated by malloc, or to a C variable). Its something the caml runtime wants not your C code. On a 32 bit =20 platform the type 'value' is a 32 bit integer so when your return =20 your double with CAMLreturn it is cast to a 32 bit integer [1] and =20 then after that cast again to a double. Hence you lose the fractional =20= part. It doesn't make sense to use CAMLreturn with anything but a =20 caml value. Best, Daniel [1] Have a look at the definition of CAMLreturn in .=