Last active
August 29, 2015 14:02
-
-
Save kmassada/6fbcf16d689c6c4c1876 to your computer and use it in GitHub Desktop.
decimal to hex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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