From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 5D7FB7F0A3 for ; Wed, 2 Sep 2015 22:56:24 +0200 (CEST) IronPort-PHdr: 9a23:68Jc0R18dKTG/LmhsmDT+DRfVm0co7zxezQtwd8ZsegeKfad9pjvdHbS+e9qxAeQG96Lt7Qc0aGP7vGocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC04LvjavrpsybSj4LrQT+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf9d32JiKAHbtR/94sCt4MwrqHwI6LoJvvRNWqTifqk+UacQTHF/azh0t4XXskzzRBWO62FUdmgMlQsAVzjM8hD3RNHVvzH9p8J83jObNIv4V+Zndy6l6vJCThPyhS4cfwQ+63rdh9Z/xPZBpwm6rRFlzKbReIDQL+VlOKTHcoVJFiJ6Qs9NWnkZUcuHZIwVAr9EZL4Aog== Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=rossberg@mpi-sws.org; spf=Pass smtp.mailfrom=rossberg@mpi-sws.org; spf=None smtp.helo=postmaster@hera.mpi-klsb.mpg.de Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of rossberg@mpi-sws.org) identity=pra; client-ip=139.19.1.49; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rossberg@mpi-sws.org"; x-sender="rossberg@mpi-sws.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of rossberg@mpi-sws.org designates 139.19.1.49 as permitted sender) identity=mailfrom; client-ip=139.19.1.49; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rossberg@mpi-sws.org"; x-sender="rossberg@mpi-sws.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@hera.mpi-klsb.mpg.de) identity=helo; client-ip=139.19.1.49; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="rossberg@mpi-sws.org"; x-sender="postmaster@hera.mpi-klsb.mpg.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DmAAC9YedVhDEBE4tdhFi9TAEJh3ICgXMUAQEBAQEBAQEQAQEBCgcECQkhLoIdggcBAQMBJxMGAQE3AQQLC0ZXBhOIJgi1JIVWAQWQDgEBAQEBAQEDAQEBAQEBAQEBEwaJAoJshFgzB4MYgRQBkjCDHY5AhyuODoNsgimBf2+CTQEBAQ X-IPAS-Result: A0DmAAC9YedVhDEBE4tdhFi9TAEJh3ICgXMUAQEBAQEBAQEQAQEBCgcECQkhLoIdggcBAQMBJxMGAQE3AQQLC0ZXBhOIJgi1JIVWAQWQDgEBAQEBAQEDAQEBAQEBAQEBEwaJAoJshFgzB4MYgRQBkjCDHY5AhyuODoNsgimBf2+CTQEBAQ X-IronPort-AV: E=Sophos;i="5.17,456,1437429600"; d="scan'208";a="144551380" Received: from infao0809.mpi-klsb.mpg.de (HELO hera.mpi-klsb.mpg.de) ([139.19.1.49]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 02 Sep 2015 22:56:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mpi-sws.org; s=mail200803; h=To:References:Message-Id:Content-Transfer-Encoding:Cc:Date:In-Reply-To:From:Content-Type:Mime-Version:Subject; bh=H97NhfscPXThUOyCfA3LZrbHe8Ie0n8wXAXC2Hp7U7Q=; b=DlXu6vvRYNApnmwLm28xDxQqzKtDQ2yNchD7yx0QenWB6fSuoU+hMqzrXuJUsq2BFqmAOT4FNGdqNHChzSGpm6uM+hG6E+dwm7uBnBS92mFgpj2eAKrOJ2B4Fnm4LJUWcBKVmpZmpvih5z+DUUrbc+EnWp+bGEo//D9fYfRnNYE=; Received: from srv-00-125.mpi-klsb.mpg.de ([139.19.1.28]:57660 helo=maniac.mpi-klsb.mpg.de) by hera.mpi-klsb.mpg.de (envelope-from ) with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) id 1ZXF4u-0004fw-Ht; Wed, 02 Sep 2015 22:56:22 +0200 Received: from 209-82-80-116.dedicated.allstream.net ([209.82.80.116]:49170 helo=[10.199.3.29]) by maniac.mpi-klsb.mpg.de (envelope-from ) with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) id 1ZXF4t-0002bg-Q5; Wed, 02 Sep 2015 22:56:19 +0200 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) Content-Type: text/plain; charset=us-ascii From: Andreas Rossberg In-Reply-To: Date: Wed, 2 Sep 2015 22:56:17 +0200 Cc: Ocaml Mailing List Content-Transfer-Encoding: quoted-printable Message-Id: <05537591-83A6-4D2E-B8FE-915379FCB12C@mpi-sws.org> References: <1D9E71FC-1C39-4655-9258-1F2CB85BAF3D@mpi-sws.org> To: Xavier Leroy X-Mailer: Apple Mail (2.2070.6) X-MPI-Local-Sender: true Subject: Re: [Caml-list] NaN reresentations On Sep 2, 2015, at 21:14 , Xavier Leroy wrote: > 2015-09-02 10:56 GMT-07:00 Andreas Rossberg : > > Does the Ocaml implementation make guarantees about the stable represen= tation of floats? In particular, if I use Int64.float_of_bits to create a p= articular NaN representation, am I guaranteed that its bit pattern is maint= ained no matter where the value is stored or passed? >=20 > It depends on the underlying hardware. For instance, with x86-32 bits, s= ome FP moves go through the x87 FP stack, undergoing a double -> extended -= > double conversion. These conversions turn signaling NaNs into quiet NaN= s, and I'm not sure they preserve the other bits of the NaN payload. >=20 > On other platforms, esp. x86-64 bits, I'm pretty confident that NaN bits = are preserved by copying and parameter passing. I see. Okay, in that case it seems safer not to rely on it, for the sake of= portability. > > We are currently in the process of implementing a reference interpreter= for a little low-level language, and that tries to be as accurate as possi= ble about float representations. >=20 > One possibility would be to represent your floats as int64 values (=3D th= eir bit-level representation), and convert only when you operate over them,= e.g. >=20 > let fp_add x y =3D Int64.bits_of_float (Int64.float_of_bits x +. Int64.fl= oat_of_bits y) Right, that is the approach we are currently discussing. but I was wonderin= g whether it is necessary. Thanks! /Andreas