home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / PILOT / PC / JUMP / PALMOS.ZIP / palmos / Pfloat.java < prev    next >
Encoding:
Java Source  |  1996-12-02  |  1.5 KB  |  72 lines

  1. package palmos;
  2.  
  3. // This is a class that provides an interface to the PalmOS floating point
  4. // library routines. This side (the Java side) should be complete, but the
  5. // assembler side in native-Pfloat.asm is not complete. Attempting to use
  6. // this class right now won't work.
  7.  
  8. public class Pfloat extends Number {
  9.   // data fields must be in this order to match PalmOS FloatType
  10.   private int man;
  11.   private short exp;
  12.   private byte sign;
  13.  
  14.   public static native int init(); // FplInit
  15.  
  16.   public static native void free(); // FplFree
  17.  
  18.   public Pfloat()
  19.   {
  20.   }
  21.  
  22.   public Pfloat(int x)
  23.   {
  24.     initInt(x);
  25.   }
  26.  
  27.   public Pfloat(String s)
  28.   {
  29.     initString(s);
  30.   }
  31.  
  32.   public Pfloat(Pfloat f)
  33.   {
  34.     man = f.man;
  35.     exp = f.exp;
  36.     sign = f.sign;
  37.   }
  38.  
  39.   private native void initInt(int x); // FplLongToFloat
  40.  
  41.   private native void initString(String s); // FplAtoF
  42.  
  43.   public native String toString(); // FplFToA
  44.  
  45.   public native int base10Info(Integer mantissa, Integer exponent, Integer sign); // FplBase10Info
  46.  
  47.   public native int intValue(); // FplFloatToLong
  48.  
  49.   public long longValue()
  50.   {
  51.     return intValue();
  52.   }
  53.  
  54.   public float floatValue()
  55.   {
  56.     return intValue();
  57.   }
  58.  
  59.   public double doubleValue()
  60.   {
  61.     return intValue();
  62.   }
  63.  
  64.   public native Pfloat add(Pfloat a, Pfloat b); // FplAdd
  65.  
  66.   public native Pfloat sub(Pfloat a, Pfloat b); // FplSub
  67.  
  68.   public native Pfloat mul(Pfloat a, Pfloat b); // FplMul
  69.  
  70.   public native Pfloat div(Pfloat a, Pfloat b); // FplDiv
  71. }
  72.