[GHC] #5683: bug in signum function

GHC ghc-devs at haskell.org
Sat Mar 26 15:58:22 UTC 2016


#5683: bug in signum function
-------------------------------------+-------------------------------------
        Reporter:  tristes_tigres    |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  7.6.1
       Component:  Prelude           |              Version:  7.0.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Other             |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by johnw42):

 Aside from preserving NaN, there's also a question of whether -0.0 should
 be mapped to 0.0 or left alone.  IMHO it should be left unchanged because
 it permits a nice symmetric implementation:

 {{{#!hs
 signum x | x > 0     =  1
          | x < 0     = -1
          | otherwise =  x
 }}}

 Aside: there's some good discussion
 [http://stackoverflow.com/questions/1986152/why-doesnt-python-have-a-sign-
 function here] of why Python has no signum function.  I guess that ship
 has sailed for Haskell, but it makes me inclined to think there's no
 universally correct definition, which is why I think having a pretty
 implementation is as good a reason as any to settle on a definition for
 the edge cases.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/5683#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list