JuliaMath / JuliaMath/FixedPointNumbers.jl
Wrong printing of `Fixed` numbers
- Vorherrschende Sprache
- Julia
- Sterne
- 95
- Forks
- 38
- Ø Merge
- 13 Min.
- Gemergte PRs (30 T.)
- 2
Beschreibung
Either I have totally misunderstood the documentation or printing of `Fixed` numbers is wrong.
```
julia> Fixed{Int8,2}(0.25)
0.2Q5f2
julia> Fixed{Int8,3}(0.125)
0.12Q4f3
```
Looking into `FixedPointNumbers.jl/show` leads to
```
digits=ceil(Int, f * log10_2)
```
which is wrong, as for `2^-f` the number of decimal fraction digits scales linearly and not logarithmic with `f`'s number of binary fraction digits, as you can see here
```
julia> 2.0.^(-1:-1:-10)
10-element Vector{Float64}:
0.5
0.25
0.125
0.0625
0.03125
0.015625
0.0078125
0.00390625
0.001953125
0.0009765625
```
Consequently this can be fixed by using `digits=f`.
Beitragsleitfaden
Rechercherichtung
Read the FixedPointNumbers.jl/show implementation, focusing on how the decimal digit count is calculated for fixed-point values. Reproduce the two examples from the issue and verify that the output uses enough fractional digits to represent Fixed{Int8,2}(0.25) and Fixed{Int8,3}(0.125) correctly.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- julia
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- Unter einer Stunde
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100