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

Algorithm 在Scheme中将字节字符串转换为Int,algorithm,scheme,byte,Algorithm,Scheme,Byte,我有这样的代码将十六进制转换成字节字符串 (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

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

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


我不确定这是否是您正在寻找的,或者即使您正在使用,但是如果您这样做,那么您应该查看PLT中的
整数字节->整数
整数->整数字节
函数。请注意,这些函数会创建包含二进制内容的字节字符串——因此它可能与您在这里尝试执行的操作不同


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

如果这是家庭作业的一部分,那么你的老师可能会要求你写一个解决方案。