the `isone` predicate throws instead of returning `false`

Open Beginner friendly
#310 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
julia
Domain
backend

Research direction

Start with the rawone and oneunit paths in src/fixed.jl and src/FixedPointNumbers.jl, then rerun the Julia 1.11.3 reproduction from the issue. Verify the isone(0.0Q0f15) behavior against the reported expectation. Done means the predicate returns false instead of throwing an ArgumentError.

Written by the indexing model from the issue text.

Description

julia> using FixedPointNumbers

julia> isone(0.0Q0f15)
ERROR: ArgumentError: Q0f15 is a 16-bit type representing 65536 values from -1.0 to 0.99997; cannot represent 1
Stacktrace:
 [1] throw_converterror(::Type{Q0f15}, x::Int64)
   @ FixedPointNumbers ~/.julia/packages/FixedPointNumbers/Dn4hv/src/FixedPointNumbers.jl:326
 [2] rawone(::Type{Q0f15})
   @ FixedPointNumbers ~/.julia/packages/FixedPointNumbers/Dn4hv/src/fixed.jl:41
 [3] oneunit(::Type{Q0f15})
   @ FixedPointNumbers ~/.julia/packages/FixedPointNumbers/Dn4hv/src/FixedPointNumbers.jl:108
 [4] one(::Type{Q0f15})
   @ FixedPointNumbers ~/.julia/packages/FixedPointNumbers/Dn4hv/src/FixedPointNumbers.jl:109
 [5] one(x::Q0f15)
   @ FixedPointNumbers ~/.julia/packages/FixedPointNumbers/Dn4hv/src/FixedPointNumbers.jl:222
 [6] isone(x::Q0f15)
   @ Base ./number.jl:62
 [7] top-level scope
   @ REPL[2]:1

julia> versioninfo()
Julia Version 1.11.3
Commit d63adeda50d (2025-01-21 19:42 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver2)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Environment:
  JULIA_NUM_PRECOMPILE_TASKS = 4
  JULIA_PKG_PRECOMPILE_AUTO = 0

(@v1.11) pkg> st FixedPointNumbers
Status `~/.julia/environments/v1.11/Project.toml`
  [53c48c17] FixedPointNumbers v0.8.5
Dominant language
Julia
Stars
95
Forks
38
Avg merge
13m
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaMath/FixedPointNumbers.jl

All issues in JuliaMath/FixedPointNumbers.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.