caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Frederic van der Plancke <fvdp@decis.be>
To: "O'Caml Mailing List" <caml-list@inria.fr>
Subject: Re: [Caml-list] int/float_of_string
Date: Mon, 23 Jun 2003 09:55:50 +0200	[thread overview]
Message-ID: <3EF6B286.44DFEBFF@decis.be> (raw)
In-Reply-To: <20030620.193537.41989199.debian00@tiscali.be>



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


  reply	other threads:[~2003-06-23  7:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-20 17:35 Christophe TROESTLER
2003-06-23  7:55 ` Frederic van der Plancke [this message]
2003-06-24  6:53 ` Pierre Weis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3EF6B286.44DFEBFF@decis.be \
    --to=fvdp@decis.be \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).