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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id B0C6C7EEBF for ; Thu, 23 Jul 2015 11:08:18 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of misterherr@freenet.de) identity=pra; client-ip=195.4.92.92; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="misterherr@freenet.de"; x-sender="misterherr@freenet.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of misterherr@freenet.de) identity=mailfrom; client-ip=195.4.92.92; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="misterherr@freenet.de"; x-sender="misterherr@freenet.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout2.freenet.de) identity=helo; client-ip=195.4.92.92; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="misterherr@freenet.de"; x-sender="postmaster@mout2.freenet.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DGAACArrBVnFxcBMNbgmmBAGmDI7omhgUCgVVMAQEBAQEBEgEBAQEBBg0JCSEuhCQBAQQjFTYKEQsYAgIFFgsCAgkDAgECAUUTCAEBiBQBFgMBtVmQGAmBMwGESAELIIEiiiqEHTY6F4JSgUMFhxKNTgGEdYkIhB2CawOQTIQkbYJLAQEB X-IPAS-Result: A0DGAACArrBVnFxcBMNbgmmBAGmDI7omhgUCgVVMAQEBAQEBEgEBAQEBBg0JCSEuhCQBAQQjFTYKEQsYAgIFFgsCAgkDAgECAUUTCAEBiBQBFgMBtVmQGAmBMwGESAELIIEiiiqEHTY6F4JSgUMFhxKNTgGEdYkIhB2CawOQTIQkbYJLAQEB X-IronPort-AV: E=Sophos;i="5.15,529,1432591200"; d="scan'208";a="171342077" Received: from mout2.freenet.de ([195.4.92.92]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 23 Jul 2015 11:08:18 +0200 Received: from [195.4.92.140] (helo=mjail0.freenet.de) by mout2.freenet.de with esmtpa (ID misterherr@freenet.de) (port 25) (Exim 4.85 #1) id 1ZICUC-0000iF-Qx for caml-list@inria.fr; Thu, 23 Jul 2015 11:08:16 +0200 Received: from localhost ([::1]:57805 helo=mjail0.freenet.de) by mjail0.freenet.de with esmtpa (ID misterherr@freenet.de) (Exim 4.85 #1) id 1ZICUC-0001gs-Ov for caml-list@inria.fr; Thu, 23 Jul 2015 11:08:16 +0200 Received: from mx11.freenet.de ([195.4.92.21]:40200) by mjail0.freenet.de with esmtpa (ID misterherr@freenet.de) (Exim 4.85 #1) id 1ZICRn-0004yO-7a for caml-list@inria.fr; Thu, 23 Jul 2015 11:05:47 +0200 Received: from cl-252.ham-02.de.sixxs.net ([2001:6f8:1c00:fb::2]:33858) by mx11.freenet.de with esmtpsa (ID misterherr@freenet.de) (TLSv1.2:DHE-RSA-AES128-SHA:128) (port 465) (Exim 4.85 #1) id 1ZICRm-0000Kx-Tr for caml-list@inria.fr; Thu, 23 Jul 2015 11:05:47 +0200 To: caml-list@inria.fr References: <20150723083517.GA2029@pl-59055.rocqadm.inria.fr> <55B0A9D5.4000008@inria.fr> From: "Mr. Herr" Message-ID: <55B0AE69.1080202@freenet.de> Date: Thu, 23 Jul 2015 11:05:45 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55B0A9D5.4000008@inria.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Originated-At: 2001:6f8:1c00:fb::2!33858 Subject: Re: [Caml-list] Comparing floats On 23.07.2015 10:46, Francois Berenger wrote: > On 07/23/2015 10:35 AM, S=C3=A9bastien Hinderer wrote: >> Dear all, >> >> What's the most efficient way to compare floats, please? >> Is it the polymorphic compare function, or is there a more specialized >> version of it? >> >> I saw Float.compare mentionned on the web but that does not seem to exist >> any longer? > > It exists in Batteries for sure and in Core I believe. > > Also, maybe you can define: > > let cmp_f (x: float) (y: float) =3D x -. y hmm, this will return float instead of int. My test says that compare is compiled directly to the adequate internal fun= ction, and if this even in byte code: str@s131-intel:~/Projekte/Ocaml/ml> cat test_comparefl1.ml && echo -e=20 "------------\n" && ocamlc -dinstr test_comparefl1.ml (* Frage auf mailing list: wie am besten floats vergleichen? *) print_endline ("Pervasives.compare 2 floats gives me " ^ (string_of_int (co= mpare 2.0=20 3.99))) ------------ const 3.99 push const 2.0 ccall caml_float_compare, 2 push getglobal Pervasives! getfield 19 apply 1 push const "Pervasives.compare 2 floats gives me " push getglobal Pervasives! getfield 15 apply 2 push getglobal Pervasives! getfield 30 apply 1 makeblock 0, 0 setglobal Test_comparefl1! ------------------------------ /Str.