-
Notifications
You must be signed in to change notification settings - Fork 33
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
Wrong printing of Fixed
numbers
#307
Comments
The printing may not be accurate, but it is not wrong. julia> 0.1f0
0.1f0
julia> big(0.1f0)
0.100000001490116119384765625 This inexact printing confuses many newbies, but exact printing is also not what everyone is looking for. This package also provides Personally, I think an additional digit would be nice. However, it is not essential in round-tripness and is a matter of preference. |
That is an interesting perspective. Thanks for sharing it. When comparing fixed-point numbers with floating-point numbers I agree that this is only a matter of accuracy. I also understand that normed numbers (as in In my mental model fixed-point numbers (as in
is the same as if we'd have
I know this, because I spent like 10 minutes reading through the documentation again and again, checking my one-liner for bugs and questioning my understanding of fixed point numbers until I finally looked at the source and saw that the printing does not print out the correct (identical to the internal representation) result. Would you accept a PR with this change for |
As noted above, there is a distinct difference there in terms of round-tripability. julia> Fixed{Int8,2}(0.25) == 0.2Q5f2
true
julia> UInt8(25) == 20
false The direct solution to the time wasting problem you have experienced would be to add documentation. I am in favor of setting a lower bound for It would be nice if julia or the REPL had a mechanism to control the number of digits displayed, but as far as I know, they do not. |
Ah, thanks, I only now understood what you meant with round-tripability.
I agree that it is not necessary in terms of the entropy. However, printing out numbers is generally not fully entropy-optimized, otherwise we wouldn't print binary numbers in decimal (the
I think the
So I guess a compromise could be to print the entropy-optimized, round-trippable number when Would that work for you? |
Although FPN v0.9 has been under development for a very long time, it does support the This package is not mine, and I would rather that the development of this package evolve independent of me. If you are willing to take responsibility for the change (i.e., help us resolve some remaining tasks and release the change as v0.9 or backport it to v0.8), I have no reason to oppose your proposal. |
Either I have totally misunderstood the documentation or printing of
Fixed
numbers is wrong.Looking into
FixedPointNumbers.jl/show
leads towhich is wrong, as for
2^-f
the number of decimal fraction digits scales linearly and not logarithmic withf
's number of binary fraction digits, as you can see hereConsequently this can be fixed by using
digits=f
.The text was updated successfully, but these errors were encountered: