Clojure

Incorrect long division involving Long/MIN_VALUE

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test
  • Approval:
    Triaged

Description

user=> (/ Long/MIN_VALUE -1)
-9223372036854775808

Similar issue to CLJ-1222, with the same root cause as described for CLJ-1225.

Activity

Hide
Andy Fingerhut added a comment -

Patch clj-1253-1.txt corrects LongOps method divide for the case of args Long/MIN_VALUE and -1. It returns a BigInt in this case, not a Long, but most other pairs of values passed to this function return a Ratio exact answer, so it seems reasonable in this one case to return a BigInt exact answer when it will not fit in a Long.

Show
Andy Fingerhut added a comment - Patch clj-1253-1.txt corrects LongOps method divide for the case of args Long/MIN_VALUE and -1. It returns a BigInt in this case, not a Long, but most other pairs of values passed to this function return a Ratio exact answer, so it seems reasonable in this one case to return a BigInt exact answer when it will not fit in a Long.
Andy Fingerhut made changes -
Field Original Value New Value
Attachment clj-1253-1.txt [ 12241 ]
Alex Miller made changes -
Labels math
Andy Fingerhut made changes -
Patch Code and Test [ 10002 ]
Alex Miller made changes -
Approval Triaged [ 10120 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: