JuliaMath / JuliaMath/FixedPointNumbers.jl

support converting between different fixed-point representations

Open
#97 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Julia
Stars
95
Forks
38
Avg merge
13m
Merged PRs (30d)
2

Description

If I have a 24-bit fixed-point number `x` I might represent it as a `Fixed{Int32, 23}`. If I later wanted to widen it to a 32-bit number to get extra precision, I might try `convert(Fixed{Int32, 31}, x`, but that doesn't currently have a method. We could implement it just as a left shift.

I'm not sure what the best overflow checking behavior would be - in this case we'd worry about any values over 1 that would get lost. For a right-shift we'd get extra headroom but lose precision. Currently the float-to-fixed behavior is to throw an `InexactError` on an overflowing conversion but not when losing precision, so we could match that behavior and only need to check on left-shifts.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.