Created
March 10, 2016 23:14
-
-
Save favila/f75c2cd69ef4b9eb7104 to your computer and use it in GitHub Desktop.
Basic code pattern to get signed hex literal (for java) from an unsigned hex literal
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
(defn signed-literal [^String unsigned-hex-str] | |
(let [s (-> (Long/parseUnsignedLong unsigned-hex-str 16) | |
(Long/toString 16))] | |
(if (.startsWith s "-") | |
(str "-0x" (subs s 1)) | |
(str "0x" s)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment