[llvm-commits] CVS: llvm-java/test/Programs/SingleSource/UnitTests/FloatCompare.java
Alkis Evlogimenos
alkis at cs.uiuc.edu
Thu Feb 17 20:30:03 PST 2005
Changes in directory llvm-java/test/Programs/SingleSource/UnitTests:
FloatCompare.java updated: 1.4 -> 1.5
---
Log message:
Improve test case.
---
Diffs of the changes: (+28 -7)
FloatCompare.java | 35 ++++++++++++++++++++++++++++-------
1 files changed, 28 insertions(+), 7 deletions(-)
Index: llvm-java/test/Programs/SingleSource/UnitTests/FloatCompare.java
diff -u llvm-java/test/Programs/SingleSource/UnitTests/FloatCompare.java:1.4 llvm-java/test/Programs/SingleSource/UnitTests/FloatCompare.java:1.5
--- llvm-java/test/Programs/SingleSource/UnitTests/FloatCompare.java:1.4 Sat Dec 11 17:31:49 2004
+++ llvm-java/test/Programs/SingleSource/UnitTests/FloatCompare.java Thu Feb 17 22:29:50 2005
@@ -1,14 +1,35 @@
public class FloatCompare
{
- public static void main(String[] args) {
- int count = 0;
+ private static float[] doubles =
+ new float[]{ -1.0f, 0.0f, -0.0f, 1.0f,
+ Float.NaN,
+ Float.NEGATIVE_INFINITY,
+ Float.POSITIVE_INFINITY };
- for (float f = 0.0F; f < 10F; f += 1.1F)
- ++count;
+ public static void main(String[] args) {
+ int greater = 0;
+ int equal = 0;
+ int less = 0;
+ int unordered = 0;
- for (double d = 100; d > 0; d -= 11)
- ++count;
+ for (int i = 0; i < doubles.length; ++i) {
+ double a = doubles[i];
+ for (int j = 0; j < doubles.length; ++j) {
+ double b = doubles[j];
+ if (a > b)
+ ++greater;
+ else if (a < b)
+ ++less;
+ else if (a == b)
+ ++equal;
+ else
+ ++unordered;
+ }
+ }
- Test.println(count);
+ Test.println(greater);
+ Test.println(equal);
+ Test.println(less);
+ Test.println(unordered);
}
}
More information about the llvm-commits
mailing list