next up previous
Next: 8.1.4 複素数(complex number) Up: 8.1 数 Previous: 8.1.2 分数(ratio)

8.1.3 浮動小数点数(floating-point number)

浮動小数点数には表現する精度の種類がいくつかあります. 倍精度では,dで指数部を表します.
<cl> pi        ;; CommonLispに組み込みです.
3.141592653589793d0 
<cl> (= pi 3.141592653589793d0)
T 
<cl> (= pi 3.141592653589793)
NIL
<cl> (asin 1)
1.5707964          ;; 倍精度ではない.
<cl> (= (asin 1) (/ pi 2)) ;; 等しくない.
NIL 
<cl> (asin 1.0d0)
1.5707963267948966d0 
<cl> (= (asin 1.0d0) (/ pi 2)) ;; これで等しい
T 
<cl> (sin (/ pi 2))
1.0d0 
<cl> (asin (sin (/ pi 2)))
1.5707963267948966d0 
<cl> (= (/ pi 2) (asin (sin (/ pi 2))))
T 
<cl> (= (atan (sin (/ pi 2)) (cos (/ pi 2))) (/ pi 2))
1.5707963267948966d0 
<cl> (= (atan (sin (/ pi 2)) (cos (/ pi 2))) (/ pi 2))
T 
<cl> (eq (atan (sin (/ pi 2)) (cos (/ pi 2))) (/ pi 2))
NIL


generated through LaTeX2HTML. M.Inaba 平成18年5月7日