Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Float literals
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-27 (04:46)
From: Edgar Friendly <thelema314@g...>
Subject: Re: [Caml-list] Float literals
Jon Harrop wrote:
> On Tuesday 26 June 2007 21:38:26 Erik de Castro Lopo wrote:
>> I do not find the second last case odd (all languages I have used
>> consider that a float), but I do for the last one.
> Would you like:
>   float_of_string "55378008"
> to work?
Yes, I would.  Somehow there's a difference between user input and
program code.  For user input, you want to be pretty permissive in what
you accept.  I guess you could force the programmer to write
    float_of_string str
    Failure _ ->
      int_of_string str
but there's all sorts of corner cases in that, from alternate bases to
range issues.

But technically it's a violation of spec, as the note (that I missed
before) in the float-literal definition about requiring either an
exponent or a decimal part of the number should apply here too.