andreiformiga
2018-5-6 21:26:33
what’s the easiest way to format a hex number with fixed width and leading zeros? example: number 7 width 4 -> 0007
dedbox
2018-5-6 21:51:25
@andreiformiga how about bytes->hex-string
?
dedbox
2018-5-6 21:53:48
If you have a number and you want a string, maybe use integer->integer-bytes
first.
dedbox
2018-5-6 21:54:23
racket@> (require file/sha1)
racket@> (bytes->hex-string (integer->integer-bytes #x000f 2 #f #t))
"000f"
andreiformiga
2018-5-6 23:02:20
@dedbox I didn’t know about bytes->hex-string
, thanks (though I’m not sure about having to import the whole module just for this function)
dedbox
2018-5-6 23:05:17
Then import just that function (require (only-in file/sha1 bytes->hex-string))