[GHC] #14377: false result in the addition
GHC
ghc-devs at haskell.org
Sat Oct 21 19:22:29 UTC 2017
#14377: false result in the addition
-------------------------------------+-------------------------------------
Reporter: vanto | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Resolution: | 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: |
-------------------------------------+-------------------------------------
Changes (by vanto):
* status: closed => new
* resolution: invalid =>
Comment:
Replying to [[span(style=color: #FF0000, nickkuk )]]:\\
Thank you.
{{{
Prelude> :t 1.1+2.2
1.1+2.2 :: Fractional a => a
}}}
I know the failures with real numbers in calculations on computers.
OK, but overall we could be sure of the result by decreasing the
number of decimal places in real number, for example.
should we use your method with all real numbers?
I think not at all. example:\\
{{{
Prelude> 2.71828182846**3.14159265359
23.14069263280959
}}}
it's a good result.\\
Another example:\\
{{{
Prelude> fromRational(2.71828182846**3.14159265359)
<interactive>:18:14: error:
* Could not deduce (Floating Rational) arising from a use of `**'
from the context: Fractional a
bound by the inferred type of it :: Fractional a => a
at <interactive>:18:1-42
* In the first argument of `fromRational', namely
`(2.71828182846 ** 3.14159265359)'
In the expression: fromRational (2.71828182846 ** 3.14159265359)
In an equation for `it':
it = fromRational (2.71828182846 ** 3.14159265359)
}}}
I am not convinced by your answer.
it works in a specific example but not in a general way.
I think we could do better.
I am doubtful, I reopen this ticket to have other opinions.\\
look at the difference with Hugs (Haskell 98 Compatability):\\
{{{
Hugs> 1.1+2.2
3.3 :: Double
(32 reductions, 75 cells)
Hugs> 1.111111+2.222222
3.333333 :: Double
(27 reductions, 41 cells)
Hugs> 1.11111111111111+2.22222222222222
3.33333333333333 :: Double
(27 reductions, 49 cells)
Hugs> :t 1.1+2.2
1.1 + 2.2 :: Double
}}}
Hugs calculates a lot better.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14377#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list