The computer relies on arithmetic. Here we test a variety of arithmetic
operations expressed as 32 bit two's complement binary numbers (Java's
int).
ArithmeticFixture | |||||
x | y | + | - | * | / |
0 | 0 | 0 | 0 | 0 | 0java.lang.ArithmeticException: / by zero at ArithmeticFixture.doCell(ArithmeticFixture.java:19) at Fixture.doCells(Fixture.java:84) at Fixture.doRow(Fixture.java:78) at Fixture.doRows(Fixture.java:72) at ArithmeticFixture.doRows(ArithmeticFixture.java:9) at Fixture.doTable(Fixture.java:67) at Fixture.doTables(Fixture.java:57) at Fixture.main(Fixture.java:25) |
1 | 2 | 3 | -1 | 2 | 0.5java.lang.NumberFormatException: 0.5 at java.lang.Long.parseLong(Long.java:319) at java.lang.Long.parseLong(Long.java:363) at PrimitiveFixture.parseLong(PrimitiveFixture.java:8) at PrimitiveFixture.equals(PrimitiveFixture.java:26) at ArithmeticFixture.doCell(ArithmeticFixture.java:19) at Fixture.doCells(Fixture.java:84) at Fixture.doRow(Fixture.java:78) at Fixture.doRows(Fixture.java:72) at ArithmeticFixture.doRows(ArithmeticFixture.java:9) at Fixture.doTable(Fixture.java:67) at Fixture.doTables(Fixture.java:57) at Fixture.main(Fixture.java:25) |
1 | -1 | 0 | 2 | -1 | -1 |
10000 | 10000 | 20000 | 0 | 100000000 | 1 |
100000 | 100000 | 200000 | 0 | 10000000000 1410065408 |
1 |
1000000 | 1000000 | 2000000 | 0 | 1000000000000 -727379968 |
1 |
ArithmeticColumnFixture | ||||
x | y | plus() | times() | divide() |
2 | 3 | 5 | 6 | 0.666667 |
200 | 300 | 500 | 60000 | 0.666667 |
2 | 3 | 10 5 |
10 6 |
10 0.6666667 |
200 | 3 | 5 203 |
6 600 |
0.666667 66.666664 |
2 | -3 | -1 | -6 | -0.666667 |
Summary | |
script file | /Users/ward/Documents/Java/Acceptance/Documents/arithmetic.html |
last modified | Sat Aug 17 10:24:22 PDT 2002 |
this run as of | Sat Aug 17 21:59:14 PDT 2002 |
Document prepaired by Ward Cunningham
First Version July 11, 2002
Last Update August 17, 2002