gpt4 book ai didi

julia - 为什么十六进制或二进制数的类型是 Uint64 而十进制数的类型是 Int64?

转载 作者:行者123 更新时间:2023-12-04 14:27:15 27 4
gpt4 key购买 nike

julia> typeof(-0b111)
Uint64

julia> typeof(-0x7)
Uint64

julia> typeof(-7)
Int64

我觉得这个结果有点令人惊讶。为什么数字的基数决定有符号或无符号?

最佳答案

看起来这是预期的行为:

This behavior is based on the observation that when one uses unsigned hex literals for integer values, one typically is using them to represent a fixed numeric byte sequence, rather than just an integer value.



http://docs.julialang.org/en/latest/manual/integers-and-floating-point-numbers/#integers

...似乎有点奇怪的选择。

关于julia - 为什么十六进制或二进制数的类型是 Uint64 而十进制数的类型是 Int64?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27349517/

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