Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#318 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
julia
Área
data

Línea de trabajo

Empieza ejecutando las reproducciones en REPL con Fixed{Int8, 6}(1), Fixed{Int8, 7}(1), sprint(show, ...), y el ejemplo de multiplicación de Unitful. Compara las rutas de visualización para f=6 y f=7; terminado significa que el valor f>=b-1 se muestra sin comillas adicionales y que la expresión de Unitful ya no produce el MethodError mostrado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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\""
Lenguaje dominante
Julia
Estrellas
95
Forks
38
Merge medio
1 d 7 min
PR fusionados (30 d)
4

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de JuliaMath/FixedPointNumbers.jl

Todos los issues de JuliaMath/FixedPointNumbers.jl

Issues similares

Más issues de Julia

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.