gpt4 book ai didi

algorithm - 在 Scheme 中将字节字符串转换为 Int

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:39:21 26 4
gpt4 key购买 nike

我有这样的代码将十六进制转换为字节串

(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")

我在想一个类似的函数,将二进制转换为整数,然后打印出来。最终结果是将二进制转换为十六进制。一些有用的链接: 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))

最佳答案

我不确定这是否是您要查找的内容,或者即使您正在使用 PLT ,但是如果你这样做了,那么你应该看看 are includedinteger-bytes->integerinteger->integer-bytes 函数在 PLT 中。请注意,这些创建的字节字符串具有二进制 内容——因此它可能与您在此处尝试执行的不同。

(如果您使用的是 372 版,那么您真的应该升级。)

关于algorithm - 在 Scheme 中将字节字符串转换为 Int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1597543/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com