[Haskell-beginners] question about round function

David McBride dmcbride at neondsl.com
Sun May 29 08:59:55 CEST 2011


Double doesn't have so much precision at that value.  It has nothing
to do with the round function.

Prelude> 3.499999999999999 :: Double
3.499999999999999

Prelude> 3.4999999999999999 :: Double
3.5

On Sun, May 29, 2011 at 2:39 AM, Prashant Shah <pshah.mumbai at gmail.com> wrote:
> Hi,
>
> This is my first time with Haskell.
>
> Here is what I found while trying out some examples :
>
> Prelude> round 3.499999999999999
> 3
> it :: Integer
>
> Prelude> round 3.4999999999999999
> 4
> it :: Integer
>
> ---------------
>
> Prelude> round 111111.49999999999
> 111111
> it :: Integer
> Prelude> round 111111.499999999999
> 111112
> it :: Integer
>
> Is it something to do with the CPU register size ?
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>



More information about the Beginners mailing list