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 WAA26997; Thu, 30 Oct 2003 22:37:07 +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 WAA26985 for ; Thu, 30 Oct 2003 22:37:05 +0100 (MET) Received: from decis.be ([194.78.219.157]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h9ULaa107268 for ; Thu, 30 Oct 2003 22:36:48 +0100 (MET) 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.5.R) with ESMTP id 36-md50000000041.tmp for ; Thu, 30 Oct 2003 22:36:25 +0100 Message-ID: <3FA18458.6F8F30D5@decis.be> Date: Thu, 30 Oct 2003 22:36:24 +0100 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: OCaml Mailing List Subject: Re: [Caml-list] Int overflow in literals References: <1067522012.5880.6.camel@qrnik> <20031030200519.GA19324@ucdavis.edu> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Authenticated-Sender: fplancke@decis.be X-Spam-Processed: decis.be, Thu, 30 Oct 2003 22:36:25 +0100 (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-Loop: caml-list@inria.fr X-Spam: no; 0.00; plancke:01 fvdp:01 caml-list:01 issac:01 trotts:01 marcin:01 'qrczak':01 kowalczyk:01 issac:01 compiler:01 ocaml:01 imho:01 int:01 int:01 arithmetic:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Issac Trotts wrote: > > On Thu, Oct 30, 2003 at 02:53:32PM +0100, Marcin 'Qrczak' Kowalczyk wrote: > > I understand that int overflow is not checked on arithmetic for > > efficiency reasons, but IMHO it would be better if it was checked > > at least in literals. When someone writes 10000000000, he certainly > > does not mean -737418240. > > If you want to be sure that the number is correctly stored, you can use > Int64: > > Int64.of_string "10000000000" > > Issac That was not my problem. My problem was to be able to read a list of integers from a file and be warned in case of overflow. And to be able to rely on int_of_string for that purpose. I got hit... of course now I know, but other innocent programmers may get hit in the future as well. (Not to speak of the not-so-innocent people who wrote this nice OCaml compiler ;-) Frédéric. ------------------- 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