home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
kaffe-0.5p4-src.tgz
/
tar.out
/
contrib
/
kaffe
/
test
/
floats
/
TestFloatDoubleLong.java
< prev
next >
Wrap
Text File
|
1996-09-28
|
1KB
|
53 lines
import java.lang.*;
class TestFloatDoubleLong {
static boolean failed = false;
static void test(String s, String r) {
if (!s.equals(r)) {
System.out.println("result "+s+" should be "+r);
failed = true;
}
}
static void test(long v, String r) {
test(Long.toString(v, 10), r);
}
static void test(int v, String r) {
test(Long.toString(v, 10), r);
}
static void test(float v, String r) {
test(Float.toString(v), r);
}
static void test(double v, String r) {
test(Double.toString(v), r);
}
public static void main(String args[]) {
System.out.println("Some mathmatical tests");
long l1 = 500000l;
long l2 = 400000l;
test(l1 * l2, "200000000000");
test(l1 >> 4, "31250");
test(l2 << 3, "3200000");
int i1 = 5000;
int i2 = 4000;
test(i1 * i2, "20000000");
test(i1 >> 4, "312");
test(i2 << 3, "32000");
float f1 = 500.005f;
float f2 = 400.004f;
test(f1 * f2, "200004");
double d1 = 500.005;
double d2 = 400.004;
test(d1 * d2, "200004");
String s = "Good";
if (failed)
s = "Bad";
System.out.println("Results "+s);
}
}