Scheme 鸡肉方案中pi计算的奇异输出

Scheme 鸡肉方案中pi计算的奇异输出,scheme,sicp,chicken-scheme,Scheme,Sicp,Chicken Scheme,版本信息:版本4.9.0.1(稳定性/4.9.0)(版本8b3189b)macosx-unix-clang-x86-64 该代码实际上用于SICP中的练习1.3.1: (define (product term a next b) (define (iter a result) (if (> a b) result (iter (next a) (* (term a) result)) ) )

版本信息:版本4.9.0.1(稳定性/4.9.0)(版本8b3189b)macosx-unix-clang-x86-64

该代码实际上用于SICP中的练习1.3.1:

(define (product term a next b)
    (define (iter a result)
        (if (> a b)
            result
            (iter (next a) (* (term a) result))
        )
    )
    (iter a 1)
)

(define (get-pi n)
    (define (next x) (+ x 2))
    (define (term x) (* x x))
    (* 8 n (/ (product term 4 next n) (product term 3 next (+ n 1))))
)
输出:

#;102> (get-pi 165) 
3.13208714360219
#;103> (get-pi 167)
3.13220081034665
#;104> (get-pi 169)
3.13231179078142
#;105> (get-pi 170)
0.0
为什么结果变成0.0


谢谢大家!

默认情况下,Chicken不会实现完整的数字塔。你需要这样做

我没有安装Chicken,但您可能必须使用
(精确->不精确(获取pi 170))
才能获得与以前相同的结果