[GHC] #14377: some results not expected with the addition
GHC
ghc-devs at haskell.org
Mon Oct 23 13:21:59 UTC 2017
#14377: some results not expected with the addition
-------------------------------------+-------------------------------------
Reporter: vanto | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Resolution: invalid | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by vanto):
look at these calculations:\\
{{{
a)
Prelude> (16.0/0.00002)
799999.9999999999
it :: Fractional a => a
b)
Prelude> fromRational(16.0/0.00002)
800000.0
it :: Fractional a => a
c)
Prelude> (16.0/0.00002)**2.1
2.491661103847512e12
it :: Floating a => a
d)
Prelude> (fromRational(16.0/0.00002))**2.1
2.491661103847512e12
it :: Floating a => a
e)
Prelude> 800000.0**2.1
2.491661103847512e12
it :: Floating a => a
f)
Prelude> let a = (16.0/0.00002)
a :: Fractional a => a
g)
Prelude> a
799999.9999999999
it :: Fractional a => a
h)
Prelude> a**2.1
2.491661103847512e12
it :: Floating a => a
}}}
the reference calculation will be the expression in e). the results from
c), d), e) and h) are equal and yet their calculations are different.\\
compare results from a) and b). the results are not identical.
then compare the results from c) and d). the results are identical.\\
first observation: it is not obligatory to write fromRational in front of
the numerical expression to have a correct result.
second observation: look at f) and g) and the result in h) which is
identical to the other results in c), d) or e).\\
as I said above, this demonstration shows that GHC calculates well
but the result provided in a) does not conform to our view and this
result does not come from an error due to the calculation of Floats. I
think this can be fixed. No?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14377#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list