gpt4 book ai didi

julia - Julia中数据类型的二进制表示原理

转载 作者:行者123 更新时间:2023-12-01 10:40:09 24 4
gpt4 key购买 nike

julia> type TestA
a::Int32
b::Int64
end
julia> type TestB
a::Int64
b::Int64
end

julia> sizeof(TestA),sizeof(TestB)
(16,16)

我预计 sizeof(TestA) 将是 4+8=12。


我很好奇幕后的原理。

为什么TestATestB大小一样?

ps:http://docs.julialang.org/en/latest/devdocs/object/是个好 Material

最佳答案

字节对齐就是答案。该文档指出:

Note that all objects are allocated in multiples of 4 bytes and aligned to the platform pointer size.

关于julia - Julia中数据类型的二进制表示原理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35387703/

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