Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#318 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
julia
領域
data

調査の方向性

まず、Fixed{Int8, 6}(1)、Fixed{Int8, 7}(1)、sprint(show, ...)、およびUnitfulの乗算例を使ってREPLで再現を実行します。f=6とf=7の表示経路を比較します。完了とは、値f>=b-1が余分な引用符なしで表示され、Unitful式が示されているMethodErrorを発生させなくなることです。

索引モデルが issue の本文から書いたものです。

説明

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\""
主要言語
Julia
スター
95
フォーク
38
平均マージ
1日 7分
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JuliaMath/FixedPointNumbers.jl のほかの issue

JuliaMath/FixedPointNumbers.jl の issue をすべて見る

似ている issue

Julia の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。