问题描述
我有code这样的转换为十六进制字节的字符串
I have code like this to convert hex into byte string
(define (word->bin s)
(let ((n (string->number s)))
(bytes (bitwise-and (arithmetic-shift n -24) #xFF)
(bitwise-and (arithmetic-shift n -16) #xFF)
(bitwise-and (arithmetic-shift n -8) #xFF)
(bitwise-and n #xFF))))
(word->bin "#x10000002")
我在想一个类似的功能将二进制转换成整数,然后打印出来。最终的结果是转换为十六进制二进制。一些有用的链接:的
I'm thinking of a similar function to convert binary into integers, then print it. The end result is the binary translated to hex. Some helpful links:http://download.plt-scheme.org/doc/372/html/mzscheme/mzscheme-Z-H-11.html#node_sec_11.2.1
http://docs.plt-scheme.org/reference/bytestrings.html#(def.((quote.~23~25kernel)._bytes-~3estring/utf-8))
http://docs.plt-scheme.org/reference/bytestrings.html#(def.((quote.~23~25kernel)._bytes-~3estring/utf-8))
推荐答案
我不知道这是你要找的东西,或者即使你使用的,但如果这样做,那么你应该看看整数bytes->的整数
和整型>的整数,字节
函数是在PLT包括。请注意,这些创建字节串用的二的内容 - 因此它可能比你想在这里做什么不同的
I'm not sure that this is what you're looking for, or even if you're using PLT, but if you do, then you should look at the integer-bytes->integer
and integer->integer-bytes
functions that are included in PLT. Note that these create byte strings with binary content -- so it might be different than what you're trying to do here.
(如果你使用的是372版本,那么你就应该升级。)
(And if you're using version 372, then you should really upgrade.)
这篇关于转换字节字符串的计划,以INT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!