Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`Fixed` does not fully support `fraction bits >= storage bits - 1`

Aperta
#318 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
julia
Ambito
data

Direzione di ricerca

Inizia eseguendo le riproduzioni nel REPL con Fixed{Int8, 6}(1), Fixed{Int8, 7}(1), sprint(show, ...), e l'esempio di moltiplicazione di Unitful. Confronta i percorsi di visualizzazione per f=6 e f=7; il lavoro è completato quando il valore f>=b-1 viene visualizzato senza virgolette aggiuntive e l'espressione Unitful non genera più il MethodError mostrato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

needs comments

Somehow related to #311 as it also concerns the lack of generalization, but in the other direction. If precision is really important, but range is not, we want to use all the bits to represent small numbers accepting that larger numbers, like 1, can no longer be represented.

Let b be the number of bits of the storage type and f the number of bits of the fraction. For f < b - 1 everything is fine:

using FixedPointNumbers, Unitful

julia> Fixed{Int8, 6}(1)
1.0Q1f6

julia> Fixed{Int8, 6}(1)u"m"
1.0Q1f6 m

However, for f >= b - 1 things start to break down when using units:

julia> Fixed{Int8, 7}(1)
"0.992188"

julia> Fixed{Int8, 7}(1)u"m"
ERROR: MethodError: no method matching *(::String, ::Unitful.FreeUnits{(m,), 𝐋, nothing})
The function `*` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...)
   @ Base operators.jl:642
  *(::Missing, ::Unitful.Units)
   @ Unitful ~/.julia/packages/Unitful/8Qjvg/src/units.jl:94
  *(::LinRange, ::Unitful.Units)
   @ Unitful ~/.julia/packages/Unitful/8Qjvg/src/range.jl:143
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[86]:1

The reason seems to be the additional quotes which are printed for f = 7 instead of f = 6, as can be seen above or more clearly below

julia> sprint(show, Fixed{Int8, 6}(1))
"1.0Q1f6"

julia> sprint(show, Fixed{Int8, 7}(1))
"\"0.992188\""
Lingua principale
Julia
Stelle
95
Fork
38
Merge medio
16h 31m
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di JuliaMath/FixedPointNumbers.jl

Tutte le issue di JuliaMath/FixedPointNumbers.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.