Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.3, Scala 2.11.0-M7
    • Fix Version/s: Scala 2.11.0-M8
    • Component/s: Misc Library
    • Labels:
      None

      Description

      math.abs(-0.0) returns 0.0 as it should, but (-0.0).abs returns -0.0. The reason is that math.abs directly calls java.lang.Math.abs but (-0.0).abs is implemented in Numeric.scala by checking if the value is < 0, which fails for -0.0.

      One way to fix this is to use compare instead of lt:

      scala> -0.0 compare 0
      res3: Int = -1
      
      scala> 0.0 compare 0
      res4: Int = 0
      

      There may well be other bugs involving -0.0.

        Activity

        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/pull/3325

          People

          • Assignee:
            Chris Hodapp
            Reporter:
            Ben Wing
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development