Repository: commons-numbers Updated Branches: refs/heads/master 810f26cfe -> 621aa3350
Prefer multiplication (nit-picks). Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/621aa335 Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/621aa335 Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/621aa335 Branch: refs/heads/master Commit: 621aa33504611b6579adee71836e1fe43636d2cd Parents: 810f26c Author: Gilles Sadowski <gil...@harfang.homelinux.org> Authored: Fri Feb 2 15:49:50 2018 +0100 Committer: Gilles Sadowski <gil...@harfang.homelinux.org> Committed: Fri Feb 2 15:49:50 2018 +0100 ---------------------------------------------------------------------- .../main/java/org/apache/commons/numbers/complex/Complex.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/621aa335/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java ---------------------------------------------------------------------- diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java index 422cb30..eda2d2b 100644 --- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java +++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java @@ -1094,11 +1094,11 @@ public class Complex implements Serializable { return new Complex(Double.POSITIVE_INFINITY, Double.NaN); } - final double t = Math.sqrt((Math.abs(real) + abs()) / 2); + final double t = Math.sqrt(0.5 * (Math.abs(real) + abs())); if (real >= 0) { - return new Complex(t, imaginary / (2 * t)); + return new Complex(t, 0.5 * imaginary / t); } else { - return new Complex(Math.abs(imaginary) / (2 * t), + return new Complex(0.5 * Math.abs(imaginary) / t, Math.copySign(1d, imaginary) * t); } }