benchmarks.larceny/src/sumfp.java
raw| 1 | /* SUMFP -- Compute sum of integers from 0 to 10000 using floating point */ |
| 2 | |
| 3 | class sumfp { |
| 4 | |
| 5 | static double run () |
| 6 | { |
| 7 | double i = 10000.0; |
| 8 | double n = 0.0; |
| 9 | |
| 10 | while (i >= 0.0) |
| 11 | { |
| 12 | n = n+i; |
| 13 | i = i-1.0; |
| 14 | } |
| 15 | |
| 16 | return n; |
| 17 | } |
| 18 | |
| 19 | public static void main (String args[]) |
| 20 | { |
| 21 | int i; |
| 22 | double result = 0.0; |
| 23 | |
| 24 | for (i=0; i<10000; i++) |
| 25 | result = run (); |
| 26 | |
| 27 | if (result != 50005000.) |
| 28 | System.out.println ("*** wrong result ***"); |
| 29 | } |
| 30 | } |
| 31 |