Arbitrary Precision Long Division
- 01/26/12
- 5:01PM
;So I got Long Division Working ;I was reading about the ratio ;1 / 998001 which expands to ever 3 digit sequence in order ;There was sample code in Python, but I thought I would ;write it in Common Lisp instead ;You will need a flatten procedure Doug Hoyte has a nice one posted ;(long-div 1 / 998001 3000) is makes interesting if long output (defun long-div (dividend divisor depth) (cond ((> depth 0) (flatten (list (truncate (/ dividend divisor)) (long-div (* 10 (mod dividend divisor)) divisor (- depth 1))))) (t ())))Decimal Time and Internet Time
- 01/24/12
- 1:39PM
So the number 86.4 in the previous post was not chosen at random. There are 86400 seconds in the day. So all we are doing is finding the percentage of seconds elapsed in the day and shifting the radix point over and rounding.
If one wanted to calculate the decimal day, one could add a parameter for the UTC offset to add timezone information. Shift the radix point some more and wind up with decimal Hours, and minutes. (100 beats make a decimal hour, 1 beat is a decimal minute.)
People did try to use that time system during the French Revolution but it caught on roughly as well as swatch-time did.
Common Lisp Code to Find Swatch Internet time.
- 01/20/12
- 5:41PM
; Finds the internet time, this time with an entry point and ; a nice string formatter. (defun beat () (multiple-value-bind (beat) (round (multiple-value-bind (s m h) (get-decoded-time) (/ (+ s (* 60 m) (* 3600 (+ 1 h))) 86.4))) (mod beat 1000))) (defun main () (format t "@ ~D~%" (beat))) ; #comon_lisp #swatch_internet_time #lisp
Hello Blog
- 01/20/12
- 5:40PM
This is the First Blog Post. I need to do a lot of stuff to get this working but at least it is there.
--D2