math.numeric-tower

Typo in sqrt-ratio

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

sqrt-ratio checks twice if sqrtnum is a floating-point number:

(defn- sqrt-ratio [^clojure.lang.Ratio n]
  (if (neg? n) Double/NaN
    (let [numerator (.numerator n),
          denominator (.denominator n),
          sqrtnum (sqrt numerator)]
      (if (float? sqrtnum)
        (Math/sqrt n)
        (let [sqrtden (sqrt denominator)]
          (if (float? sqrtnum)
            (Math/sqrt n)
            (/ sqrtnum sqrtden)))))))

The second check should be a check for the type of sqrtden or the check(s) should be removed (and let / do the job).

Activity

Mark Engelberg made changes -
Field Original Value New Value
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Mark Engelberg made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: