FixedPointNumbers.jl icon indicating copy to clipboard operation
FixedPointNumbers.jl copied to clipboard

[RFC] Move arithmetic functions into submodule `FixedPointArithmetic`

Open kimikage opened this issue 9 months ago • 1 comments

This is in preparation for improved overflow handling. (closes #239)

Even though these functions will be exposed differently in the future by the package extension mechanism, I believe that their implementation should be there statically.

There is a slight tradeoff between an ideal module structure and maintainability. The proposed file structure follows the conventional file structure. That is, the FixedPoint common implementations are in one arithmetic.jl, and the specializations specific to Fixed and Normed are in *_arithmetic.jl.

In terms of modularity, it might be better to have separate files for each strategy, such as Checked. However, as noted above, I do not intend for them to be loaded/compiled independently.

Submodule names such as Wrapping are also debatable. The current proposal comes from the following reasons:

  • CheckedArithmetic conflicts with the package name
  • FixedPointCheckedArithmetic, FixedPointChecked, and so on are redundant
    • They are never exported from FixedPointNumbers
  • They are the analogy with Base.Checked

The automatic formatter has removed the spaces in the type parameters, which I will try to restore later.

kimikage avatar Apr 29 '24 23:04 kimikage

Codecov Report

Attention: Patch coverage is 99.01961% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 97.02%. Comparing base (3a4346c) to head (e967034).

Files Patch % Lines
src/arithmetic/fixed_arithmetic.jl 92.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #292      +/-   ##
==========================================
+ Coverage   96.93%   97.02%   +0.08%     
==========================================
  Files           7       10       +3     
  Lines         784      806      +22     
==========================================
+ Hits          760      782      +22     
  Misses         24       24              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 29 '24 23:04 codecov[bot]