Memoize

BasicWerk   EC Support   Technique   Facebook  

20140830111714_Common_Lisp_format_d

Common_Lisp_format_d

 

 
;; 右詰め2桁
* (format t "~2d~%" 1)
 1
NIL
 
* (format t "~2d~%" 10)
10
NIL
 
;; +- 付き
* (format t "~@d~%" 10)
+10
NIL
* (format t "~@d~%" -10)
-10
NIL
 
;; 右詰め、左 0 埋め
* (format t "~10,'0d~%" 10)
0000000010
NIL
 
;; Ooops...
* (format t "~10,'0d~%" -10)
0000000-10
NIL
 
;; 3桁カンマ区切り
* (format t "~:d~%" 10000)
10,000
NIL
 
;; hex
* (format t "~x~%" 10000)
2710
NIL
 
;; Octal
* (format t "~o~%" 10000)
23420
NIL
 
;; Binary
* (format t "~b~%" 10000)
10011100010000
NIL
 
;; Float
* pi
 
3.141592653589793d0
 
;; 小数点以下4桁
* (format t "~,4f~%" pi)
3.1416
NIL
 
;; 科学記法
* (format t "~e~%" pi)
3.141592653589793d+0
NIL
 
;; 科学記法、小数点以下4桁
* (format t "~,4e~%" pi)
3.1416d+0
NIL
 

 

http://www.gigamonkeys.com/book/a-few-format-recipes.html

 


© Shin Nakamura/BasicWerk 2014