This new method in the Fixed class is needed by the new rasterizer code.
It truncates a fixed point number so that only the digits after the
point are left.

2007-05-24  Roman Kennke  <[EMAIL PROTECTED]>

        * gnu/java/math/Fixed.java
        (trunc): New method.

/Roman

-- 
Dipl.-Inf. Roman Kennke, Software Engineer, http://kennke.org
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-0
USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe
Geschäftsführer: Dr. James J. Hunt
Index: gnu/java/math/Fixed.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/math/Fixed.java,v
retrieving revision 1.1
diff -u -1 -5 -r1.1 Fixed.java
--- gnu/java/math/Fixed.java	1 Jan 2007 23:12:09 -0000	1.1
+++ gnu/java/math/Fixed.java	24 May 2007 20:56:03 -0000
@@ -97,30 +97,43 @@
   /**
    * Returns the floor value of a fixed point value <code>a</code> with
    * <code>n</code> digits.
    *
    * @param n the number of digits
    * @param a the fixed point value
    *
    * @return <code>floor(a)</code> as fixed point value
    */
   public static int floor(int n, int a)
   {
     return a & -(1 << n);
   }
 
   /**
+   * Truncates the number so that only the digits after the point are left.
+   *
+   * @param n the number of digits
+   * @param a the fixed point value
+   *
+   * @return the truncated value
+   */
+  public static int trunc(int n, int a)
+  {
+    return a & (0xFFFFFFFF >>> 32 - n);
+  }
+
+  /**
    * Returns the round value of a fixed point value <code>a</code> with
    * the <code>n</code> digits.
    *
    * @param n the number of digits
    * @param a the fixed point value
    *
    * @return <code>round(a)</code> as fixed point value
    */
   public static int round(int n, int a)
   {
     return (a + (1 << (n - 1))) & -(1 << n);
   }
 
   /**
    * Returns the fixed point value <code>a</code> with <code>n</code> digits

Reply via email to