summaryrefslogtreecommitdiff
path: root/gnu/java
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2007-05-24 20:56:35 +0000
committerRoman Kennke <roman@kennke.org>2007-05-24 20:56:35 +0000
commit4038e1edf3cc3ad4eb53f873ecf6a2fd1565c695 (patch)
tree4f32e8b7cde173060a183db67cd39521483144f9 /gnu/java
parentc559b24555d6917692118aa0245958918d389201 (diff)
downloadclasspath-4038e1edf3cc3ad4eb53f873ecf6a2fd1565c695.tar.gz
2007-05-24 Roman Kennke <roman@kennke.org>
* gnu/java/math/Fixed.java (trunc): New method.
Diffstat (limited to 'gnu/java')
-rw-r--r--gnu/java/math/Fixed.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/gnu/java/math/Fixed.java b/gnu/java/math/Fixed.java
index e0284c329..ed4150b10 100644
--- a/gnu/java/math/Fixed.java
+++ b/gnu/java/math/Fixed.java
@@ -109,6 +109,19 @@ public final class Fixed
}
/**
+ * 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.
*