Browse thread
[Caml-list] Int overflow in literals
-
Marcin 'Qrczak' Kowalczyk
- Alex Baretta
-
Issac Trotts
- Oleg Trott
- Frederic van der Plancke
- Xavier Leroy
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Frederic van der Plancke <fvdp@d...> |
| Subject: | Re: [Caml-list] Int overflow in literals |
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