Skip to content

Instantly share code, notes, and snippets.

@kmassada
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmassada/6fbcf16d689c6c4c1876 to your computer and use it in GitHub Desktop.
Save kmassada/6fbcf16d689c6c4c1876 to your computer and use it in GitHub Desktop.
decimal to hex
(define (toHex dec)
;local-function:solveHex
(define (solveHex dec res)
(let ((base 16))
(cond
[(null? dec) res]
[(>= dec (- base 1)) (solveHex (quotient dec base) (string-append (getHex (remainder dec base)) res) )]
[else (string-append (getHex dec) res)]
)
)
)
(solveHex dec "")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment