Skip to content

Instantly share code, notes, and snippets.

@sasaki-shigeo
Created October 6, 2012 05:41
Show Gist options
  • Save sasaki-shigeo/3844088 to your computer and use it in GitHub Desktop.
Save sasaki-shigeo/3844088 to your computer and use it in GitHub Desktop.
Numeric Constants and Convert Functions in Scheme
;;;
;;; 無限大と NaN
;;;
(define negative-infinity (log 0.0))
(define positive-infinity (- negative-infinity))
(define NaN (+ positive-infinity negative-infinity))
;;;
;;; 数値の変換
;;;
(floor -3.6) ; => -4.0 繰り下げ
(ceil -3.6) ; => -3.0 繰り上げ 
(truncate -3.6) ; => -3.0 切り捨て
(round -3.6) ; => -4.0 偶数丸め
(real-part 3+4i) ; => 3 実部
(imag-part 3+4i) ; => 4 虚部
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment