[Haskell-beginners] import question

Bob Ippolito bob at redivi.com
Thu Feb 18 02:36:45 UTC 2021


You don't need to do any rounding if the list is already Decimal.

If you wanted to format a Double with some specific decimal representation
you could look at Numeric.showFFloatAlt or similar.

import Data.Decimal

dList :: [Decimal]
dList = [1.00,1.01..2.00]

main = print dList



On Wed, Feb 17, 2021 at 5:27 PM Galaxy Being <borgauf at gmail.com> wrote:

> I'm trying to create a list of real numbers with a two-decimal interval, a
> la
>
> > [1.0,1.01,1.02,...1.99,2.00]
>
> however, I get the float approximation problem
>
>
> [1.0,1.01,1.02,1.03,1.04,1.05,1.06,1.07,1.08,1.09,1.1,1.11,1.12,1.1300000000000001,1.1400000000000001,...
>
> So I attempted to compensate with
>
> import Data.Decimal
> map (roundTo 2) [1.00,1.01..2.0]
>
> I don't have to do it this way if there is another rounding function to
> correct the float overrun issue.
>
>
>
> On Wed, Feb 17, 2021 at 2:43 PM Francesco Ariis <fa-ml at ariis.it> wrote:
>
>> Il 17 febbraio 2021 alle 14:17 Galaxy Being ha scritto:
>> > How would I install it globally? I'm not using projects, I'm just at the
>> > ghci REPL.
>>
>> Most likely
>>
>>     cabal install --lib Decimal
>>
>> Check what Tom has said too —F
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210217/4ef41c7d/attachment.html>


More information about the Beginners mailing list