2007-06-13 10:49:54 -04:00
|
|
|
;;; FPSUM - Compute sum of integers from 0 to 1e6 using floating point
|
|
|
|
|
2007-11-04 12:03:32 -05:00
|
|
|
(library (rnrs-benchmarks fpsum)
|
2007-06-13 10:49:54 -04:00
|
|
|
(export main)
|
2007-11-04 12:03:32 -05:00
|
|
|
(import (rnrs) (rnrs arithmetic flonums) (rnrs-benchmarks))
|
2007-06-13 10:49:54 -04:00
|
|
|
|
|
|
|
(define (run)
|
|
|
|
(let loop ((i 1e6) (n 0.))
|
|
|
|
(if (fl<? i 0.)
|
|
|
|
n
|
|
|
|
(loop (fl- i 1.) (fl+ i n)))))
|
|
|
|
|
|
|
|
(define (main . args)
|
|
|
|
(run-benchmark
|
|
|
|
"fpsum"
|
|
|
|
fpsum-iters
|
|
|
|
(lambda (result) (equal? result 500000500000.))
|
|
|
|
(lambda () run))))
|