Changeset 3566


Ignore:
Timestamp:
09/03/03 23:55:48 (19 years ago)
Author:
piso
Message:

Lisp floats are now Java doubles.

File:
1 edited

Legend:

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

    r3562 r3566  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: Complex.java,v 1.13 2003-09-02 20:02:44 piso Exp $
     5 * $Id: Complex.java,v 1.14 2003-09-03 23:55:48 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    132132            LispObject c = ((Complex)obj).getRealPart();
    133133            LispObject d = ((Complex)obj).getImaginaryPart();
     134            // xy = (ac - bd) + i(ad + bc)
     135            // real part = ac - bd
     136            // imag part = (a + b)(c + d) - ac - bd
    134137            LispObject ac = a.multiplyBy(c);
    135138            LispObject bd = b.multiplyBy(d);
     
    170173    public LispObject ABS() throws TypeError
    171174    {
    172         float real = LispFloat.coerceToFloat(realpart).getValue();
    173         float imag = LispFloat.coerceToFloat(imagpart).getValue();
    174         return new LispFloat((float)Math.sqrt(real * real + imag * imag));
     175        double real = LispFloat.coerceToFloat(realpart).getValue();
     176        double imag = LispFloat.coerceToFloat(imagpart).getValue();
     177        return new LispFloat(Math.sqrt(real * real + imag * imag));
    175178    }
    176179
Note: See TracChangeset for help on using the changeset viewer.