[GHC] #14384: real numbers, digits after the decimal point - digits of precision

#14384: real numbers, digits after the decimal point - digits of precision -------------------------------------+------------------------------------- Reporter: vanto | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- the results from computation should have eleven digits after the decimal point for real numbers. (11 digits of precision) it seems reasonable.\\ instead of: {{{ Prelude> (16.0/0.00002)**2.1 2.491661103847512e12 }}} this is better:\\ {{{ 2.49166110385e12 }}} it should be noted that a lot of computing system uses this precision. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14384 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14384: real numbers, digits after the decimal point - digits of precision -------------------------------------+------------------------------------- Reporter: vanto | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by svenpanne): * status: new => closed * resolution: => invalid Comment: Shortening like this would be wrong, because it would lose precision: {{{ Prelude> decodeFloat ((16.0/0.00002)**2.1) (5102921940679704,-11) Prelude> decodeFloat 2.49166110385e12 (5102921940684800,-11) }}} The default `Show` instance should at least produce as many digits as necessary to reproduce the underlying binary representation, otherwise a lot of code out there would be ''very'' unhappy. If you have other formatting needs, you can use e.g. `Text.Printf.printf`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14384#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14384: real numbers, digits after the decimal point - digits of precision -------------------------------------+------------------------------------- Reporter: vanto | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | 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, svenpanne )]]. \\ you misunderstood. I do not mention that I was talking about the precision of the display. Here you confuse the precision digits of the display of the result and the digits of precision of the calculation made by GHC.\\ if you misunderstood ask a question.\\ ''' And please, stop closing my tickets because you do not agree or you understand nothing. you are not alone here. '''\\ this ticket is reopened. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14384#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14384: real numbers, digits after the decimal point - digits of precision -------------------------------------+------------------------------------- Reporter: vanto | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by hsyl20): * status: new => closed * resolution: => invalid Comment: Replying to vanto: It seems like you are new to Haskell (and to programming with floating- point numbers in general). `read . show` must be `id`. Do you understand the following code? {{{#!hs
read (show ((16.0/0.00002)**2.1)) - (((16.0/0.00002)**2.1) :: Double) 0.0 read "2.49166110385e12" - (((16.0/0.00002)**2.1) :: Double) 2.48828125 }}}
Use `printf` as suggested or [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#us... -custom-interactive-printing-function `-interactive-print` in GHCi]. Please use the haskell-beginners mailing-list to ask questions instead of GHC's bug tracker when you don't understand. You are not alone here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14384#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14384: real numbers, digits after the decimal point - digits of precision -------------------------------------+------------------------------------- Reporter: vanto | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | 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, hsyl20 )]] \\ look what I wrote in ticket {{{#14377}}} and hope you understand.\\ because this ticket is an idea for a possible improvement of GHC. That's all. and I do not want to change anything else! yes I am new to Haskell language and I certainly have abilities in areas that you do not have. It's not good to tell me what you say because you know more than me the language. Here I do not need help, I only bring some ideas that maybe someday will be used to improve GHC. That's all I want. and I still know how to close a ticket myself if it does not fit the majority. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14384#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14384: real numbers, digits after the decimal point - digits of precision -------------------------------------+------------------------------------- Reporter: vanto | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: wontfix | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by svenpanne): * status: new => closed * resolution: => wontfix -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14384#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14384: real numbers, digits after the decimal point - digits of precision -------------------------------------+------------------------------------- Reporter: vanto | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by vanto): * status: closed => new * resolution: wontfix => Comment: This ticket shows a future request. You have expressed your point of view, others can express themselves too. Please, svenpanne, stop to close this ticket. I re-open it.\\ I add that with the Ada language we can change the number of digits of precision and that we can be inspired by it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14384#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14384: real numbers, digits after the decimal point - digits of precision -------------------------------------+------------------------------------- Reporter: vanto | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by hsyl20): * status: new => closed * resolution: => invalid Comment: The feature already exists. {{{#!haskell {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleInstances #-} import Text.Printf class MyPrint a where myshow :: a -> IO () default myshow :: Show a => a -> IO () myshow = print instance MyPrint [Char] instance MyPrint Int instance MyPrint Double where myshow d = printf "%.11e\n" d }}} {{{
:load MyPrint.hs [1 of 1] Compiling Main ( MyPrint.hs, interpreted ) Ok, 1 module loaded. :set -interactive-print myshow (16.0/0.00002)**2.1 2.49166110385e12 }}}
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14384#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14384: real numbers, digits after the decimal point - digits of precision -------------------------------------+------------------------------------- Reporter: vanto | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by vanto): It's not the same thing as in the Ada language. Thank you for the demonstration. But do not think I am looking for help in the ticket. By the way, I take the opportunity to say that I knew how to answer your question.(comment3) - Book "Thinking Functionally with Haskell" Professor Richard Bird , Page 41 Exercise H. See read and show.\\ I am new, however, I acquire little by little new knowledge coming from books that I read. This ticket will remain permanently closed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14384#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC