如果我跑:
>>> import math
>>> print(math.pi)
3.141592653589793
Run Code Online (Sandbox Code Playgroud)
然后pi打印16位数,
但是,根据:
>>> import sys
>>> sys.float_info.dig
15
Run Code Online (Sandbox Code Playgroud)
我的精度是15位数.
那么,我应该依赖该值的最后一位(即π的值确实是3.141592653589793nnnnnn).
objectid()Julia 中的、hash()、pointer()和有什么区别pointer_from_objref()?
与 进行比较的运算符是什么===?
julia> L1 = [1,2,3];
julia> L2 = L1;
julia> L3 = copy(L1);
julia> objectid(L1), objectid(L2), objectid(L3)
(0xac55c2b098913d98, 0xac55c2b098913d98, 0xbdee7946bbc068f0)
julia> hash(L1), hash(L2), hash(L3)
(0xecc5186e7be222c6, 0xecc5186e7be222c6, 0xecc5186e7be222c6)
julia> pointer_from_objref(L1), pointer_from_objref(L2), pointer_from_objref(L3)
(Ptr{Nothing} @0x00007f6888141e40, Ptr{Nothing} @0x00007f6888141e40, Ptr{Nothing} @0x00007f68881438f0)
julia> pointer(L1), pointer(L2), pointer(L3)
(Ptr{Int64} @0x00007f6888141e80, Ptr{Int64} @0x00007f6888141e80, Ptr{Int64} @0x00007f6888143930)
Run Code Online (Sandbox Code Playgroud)
从文档中:
objectid(x)
Get a hash value for x based on object identity. objectid(x)==objectid(y) if x === y.
hash(x[, h::UInt])
Compute an …Run Code Online (Sandbox Code Playgroud)