Changeset 11954


Ignore:
Timestamp:
05/26/09 18:34:23 (12 years ago)
Author:
ehuelsmann
Message:

Remove workaround for the fact that Math.hypot() was added in Java 1.5:
We require 1.5 and hence don't need to work around it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/Complex.java

    r11718 r11954  
    3333
    3434package org.armedbear.lisp;
    35 
    36 import java.lang.reflect.Method;
    3735
    3836public final class Complex extends LispObject
     
    303301  }
    304302
    305   private static Method hypotMethod = null;
    306   static { try {
    307       hypotMethod =
    308           Class.forName("java.lang.Math")
    309           .getMethod("hypot", new Class[] { Double.TYPE, Double.TYPE });
    310   }
    311   catch (Throwable t) { Debug.trace(t); }
    312   }
    313 
    314303  @Override
    315304  public LispObject ABS() throws ConditionThrowable
     
    319308    double real = DoubleFloat.coerceToFloat(realpart).value;
    320309    double imag = DoubleFloat.coerceToFloat(imagpart).value;
    321     try
    322       {
    323         if (hypotMethod != null)
    324           {
    325             Object[] args;
    326             args = new Object[2];
    327             args[0] = new Double(real);
    328             args[1] = new Double(imag);
    329             Double d = (Double) hypotMethod.invoke(null, args);
    330             if (realpart instanceof DoubleFloat)
    331               return new DoubleFloat(d.doubleValue());
    332             else
    333               return new SingleFloat((float)d.doubleValue());
    334           }
    335       }
    336     catch (Throwable t)
    337       {
    338         Debug.trace(t);
    339         // Fall through...
    340       }
    341     double result = Math.sqrt(real * real + imag * imag);
    342310    if (realpart instanceof DoubleFloat)
    343       return new DoubleFloat(result);
     311      return new DoubleFloat(Math.hypot(real, imag));
    344312    else
    345       return new SingleFloat((float)result);
     313      return new SingleFloat((float)Math.hypot(real, imag));
    346314  }
    347315
Note: See TracChangeset for help on using the changeset viewer.