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 JAA17242; Mon, 23 Jun 2003 09:51:12 +0200 (MET DST) 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 JAA15896 for ; Mon, 23 Jun 2003 09:51:11 +0200 (MET DST) Received: from decis.be ([194.78.219.157]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h5N7p8H15485 for ; Mon, 23 Jun 2003 09:51:09 +0200 (MET DST) Received: from decis.be ([192.168.0.20]) (authenticated user fplancke@decis.be) by decis.be (decis.be [194.78.219.157]) (MDaemon.PRO.v6.8.0.R) with ESMTP id 64-md50000000012.tmp for ; Mon, 23 Jun 2003 09:55:53 +0200 Message-ID: <3EF6B286.44DFEBFF@decis.be> Date: Mon, 23 Jun 2003 09:55:50 +0200 From: Frederic van der Plancke Reply-To: fvdp@decis.be Organization: Decis X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: "O'Caml Mailing List" Subject: Re: [Caml-list] int/float_of_string References: <20030620.193537.41989199.debian00@tiscali.be> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Authenticated-Sender: fplancke@decis.be X-Spam-Processed: decis.be, Mon, 23 Jun 2003 09:55:53 +0200 (not processed: message from valid local sender) X-MDRemoteIP: 192.168.0.20 X-Return-Path: fvdp@decis.be X-MDaemon-Deliver-To: caml-list@inria.fr X-Spam: no; 0.00; plancke:01 fvdp:01 caml-list:01 troestler:01 3.06:01 intentional:01 unsafe:01 christophe:01 ocaml:01 caml:01 int:01 behaviour:01 overflow:02 float:02 exception:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Christophe TROESTLER wrote: > > Hi, > > I noticed that there are some disparities in the way string are > converted to int/float : > > Objective Caml version 3.06+36 (2003-06-19) > > # int_of_string "34\000xx";; > - : int = 34 > # float_of_string "34\000xx";; > Exception: Failure "float_of_string". > > Is this intentional? I suppose it is not and float_of_string does the > right thing. And, BTW, I find the next unsafe behaviour very annoying, especially when reading text files (while I was still innocent, I got hit): # int_of_string "9876543210" ;; - : int = -860875030 # int_of_float 9876543210.0;; - : int = -860875030 Since OCaml aims to be safe, and since IMO adding an overflow check to int_of_string & relatives would not be costly (relatively speaking), I think it should be done. We could add unsafe_int_of_string-like functions for speed afficionados. Frédéric vdP ------------------- 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