Reading Floats

ketil+haskell at ketil+haskell at
Fri Oct 3 12:07:40 EDT 2003


I recently encountered something I found a bit peculiar when reading
floats from strings.  Leading zeroes seem okay, as long as there is no
decimal point.  To wit:

        Main> (map read ["1.0", "00000", "01", "01.0"]) :: [Float]
        [1.0,0.0,1.0,*** Exception: no parse

Neither is leading decimal point allowed:

        Main> (read ".01") :: Float
        *** Exception: no parse

Is this how it's supposed to be?

If I haven't seen further, it is by standing in the footprints of giants

More information about the Glasgow-haskell-users mailing list