#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
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: Other
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by tristes_tigres):
I don't quite understand what you're saying.
> "(e.g. should 7.7 be converted to 7 or 8?)."
That is determined by the function you're using: round, floor or ceil. In
the context of arithmetic operations, which way you round, say, 7.5, is
determined by IEEE rounding-mode flags.
> I think we do need truncate et al to be able to return integral types,
though:
I see two problems with that:
a) Handling of special types: Inf, NaN. They are valid floating-point
types, raisig exception on rounding them disagrees with what standard says
(and the current way they're handled by Prelude is even worse)
b) Making output of round into integral will require conversion back to
floating-point in some typical floating-point computations. For instance,
take computing of a sine. As a first step, argument is reduced to the
interval [0, pi/4] (and then rational approximation is used). Reduction
involves rounding the floating-point result of the division by pi. There's
abslutely no reason to convert it to integral.
(I speak from floating-point standard perspective)
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5683#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs