; feet and inches
(define (feet-and-inches n)
(if (zero? n) "0 feet 0 inches"
(let* ((n (+ n 1/64))
(feet (inexact->exact (floor (/ n 12))))
(inches (inexact->exact (floor (- n (* feet 12)))))
(32nds (/ (inexact->exact (floor (* (- n (* feet 12) inches) 32))) 32)))
(string-append
(if (zero? feet) "" (number->string feet))
(if (zero? feet) "" (if (= feet 1) " foot" " feet"))
(if (zero? inches) "" (if (positive? feet) " " ""))
(if (zero? inches) "" (number->string inches))
(if (zero? 32nds) ""
(if (and (zero? feet) (zero? inches)) ""
(if (zero? inches) " " " and ")))
(if (zero? 32nds) "" (number->string 32nds))
(if (and (zero? inches) (zero? 32nds)) ""
(if (or (zero? inches) (and (= inches 1) (zero? 32nds))) " inch" " inches"))))))
(for-each
(lambda (n)
(display n) (display #\tab) (display (feet-and-inches n)) (newline))
'(0 0.2785 1.6895 11.9999 12.2785 71.9999 72 72.3492 72.9999 73 73.0135 73.0185 73.8218))