From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA21267; Sat, 1 Feb 2003 15:09:50 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA20179 for ; Sat, 1 Feb 2003 15:09:29 +0100 (MET) Received: from comtv.ru (comtv.ru [217.10.32.4]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h11E9Tf09489 for ; Sat, 1 Feb 2003 15:09:29 +0100 (MET) Received: from [10.0.66.9] ([10.0.66.9] verified) by comtv.ru (CommuniGate Pro SMTP 4.0.5) with ESMTP id 6807385; Sat, 01 Feb 2003 17:09:28 +0300 Date: Sat, 1 Feb 2003 17:11:10 +0300 (MSK) From: malc X-X-Sender: malc@home.oyster.ru To: John Carr cc: Shawn Wagner , "" Subject: Re: [Caml-list] Finding the sign of a float In-Reply-To: <200302011256.HAA06393@nerd-xing.mit.edu> Message-ID: References: <200302011256.HAA06393@nerd-xing.mit.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, 1 Feb 2003, John Carr wrote: > > > I'm looking for a way, in pure ocaml without having to bail out to C, to > > tell if a float is negative or not. > > > > Just using x < 0.0 won't work, as I need to be able to tell the difference > > between -0.0 and +0.0. This is for ocaml versions of the C copysign and > > signbit functions. Any suggestions? > > x < 0.0 || (x = 0.0 && 1.0/.x < 0.0) > > may be faster than converting the bits to integer, or slower, > depending on platform and context, and how often you encounter -0. 1.0 /. x = neg_infinity less typing -- mailto:malc@pulsesoft.com ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners