Browse thread
[Caml-list] int/float_of_string
-
Christophe TROESTLER
- Frederic van der Plancke
- Pierre Weis
[
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/float_of_string |
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