-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upper limit of the number of fractional bits f
#155
Comments
I also have some concerns about the type of
Originally posted by @kimikage in #129 (comment) I think FixedPointNumbers.jl/src/normed.jl Line 8 in 08c7452
|
I think those test cases are broken, we should probably change them.
Why? |
It is reasonable to consider them broken, but we need to be careful if they have been actually used. Should we add a depwarn as usual?
You will not be able to construct Edit: |
I'm not sure that's a problem. In the end types get identified as a pointer (see |
I've been discussing the interoperability between the 32-bit and 64-bit systems since #129 (comment). If it doesn't matter, it's all fine. Edit: julia> versioninfo()
Julia Version 1.0.5
Commit 3af96bcefc (2019-09-09 19:06 UTC)
Platform Info:
OS: Windows (i686-w64-mingw32)
CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
WORD_SIZE: 32
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
julia> using JLD2, FileIO, TestImages
julia> img = testimage("cameraman");
julia> @save "cameraman.jld2" img julia> versioninfo()
Julia Version 1.3.1
Commit 2d5741174c (2019-12-30 21:36 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
julia> using JLD2, FileIO, ColorTypes
julia> @load "cameraman.jld2" img;
julia> typeof(img)
Array{Gray{Normed{UInt8,8}},2}
julia> img[1,1]
Gray{N0f8}(Error showing value of type Gray{Normed{UInt8,8}}:
ERROR: f must be an Int Of course, there is no need to save 2D images in JLD2. This is just an example. Most functions should work with FixedPointNumbers.jl/src/normed.jl Line 49 in e18c350
Perhaps adding promotion rules ( |
Now I see what you mean. This really seems like something JLD2 should handle, and not be a problem that individual packages have to worry about. IMO any time there's an integer type parameter it should just be |
It is definitely a good thing that JLD2 can handle it well. However, JLD2 is not the only serializer, and FixedPointNumbers is a somewhat famous but ordinary package, and not included in the standard library. I agree with the principle. The dimension of In any case, even if we restrict |
Is the following customization really useful? (I skeptically wrote this. ) function deserialize(s::AbstractSerializer, ::Type{Normed{T,f}}) where {T, f}
tag = read(s.io, UInt8)
reinterpret(Normed{T, Int(f)}, read(s.io, T))
end One of the troubles of customizing From an implementation point of view, I think it is simpler to use the promotion mechanism. |
Hard to say in the abstract. You've probably seen what happens right now, but I haven't poked at this issue. If you need input, a set of failing tests would be a good starting point. (I don't have access to a 32-bit machine, however.) |
I don't want to add BTW, I also think AppVeyor supports the 32-bit Windows build. Travis-ci also supports the 32-bit Linux build, but I have never tried it. I don't think |
I'm in no hurry, but I do think forcing julia> using FixedPointNumbers
julia> T1 = Normed{UInt8,8}
Normed{UInt8,8}
julia> T2 = Normed{UInt8,Int32(8)}
Normed{UInt8,8}
julia> T1 == T2
false
julia> x = T2(0.4)
0.4N0f8
julia> isa(x, N0f8)
false That's really confusing. EDIT: but please don't try to fix this by changing how types are printed. There's a long and glorious history of hard-to-debug segfaults in Julia because of well-meaning customizations of type printing. (Customizing |
I completely agree. I also think "forcing" |
In theory, the number of fractional bits
f
can be countlessly large, but what is the actual upper limit?I assumed that it is
8sizeof(T)-1
forFixed{T}
, and8sizeof(T)
forNormed{T}
.However, the larger numbers are also used actually.
FixedPointNumbers.jl/test/fixed.jl
Line 63 in 7ad0f0c
FixedPointNumbers.jl/test/fixed.jl
Line 96 in 7ad0f0c
FixedPointNumbers.jl/test/fixed.jl
Line 110 in 7ad0f0c
FixedPointNumbers.jl/test/fixed.jl
Line 138 in 7ad0f0c
Perhaps some functions do not work properly with large
f
, due to implicit upper limits.Edit:
I intend to support
Fixed{T,f}
wheref == 8sizeof(T)
, i.e. throw no exceptions. However, they have no typealias and will not be tested enough.The text was updated successfully, but these errors were encountered: