zaud #7334(2008/08/25 07:10 GMT) [ Scheme ] Rating0/0=0.00
またクラス作るパターンでやりました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/bin/env gosh (define-class <b> () ((b :init-keyword :b :accessor b-b))) (define-method write-object ((b <b>) port) (let* ((j (b-b b)) (k 1000.0) (l '(byte k M G T P E Z Y)) (m (min (truncate->exact (/ (log j) (log k))) (- (length l) 1)))) (if (< j k) (display j) (display (/ (truncate (* (/ j (expt k m)) 10)) 10))) (print (list-ref l m)))) (define (main args) (display "input: ")(flush) (print (make <b> :b (x->number(read)))))
Rating0/0=0.00-0+
[ reply ]
zaud
#7334()
[
Scheme
]
Rating0/0=0.00
Rating0/0=0.00-0+
[ reply ]