floating_bar icon indicating copy to clipboard operation
floating_bar copied to clipboard

Use macro to reduce code duplication

Open 1011X opened this issue 5 years ago • 1 comments

Right now the code between r32 and r64 is pretty much the same (as a result of copy-pasting it) except for some modifications to handle larger numbers in r64. Ideally tho, there should be a macro that handles implementations for both types in order to reduce code reuse and possible inconsistencies between them.

Such a macro should only rely on:

  • the name of the type (given to the macro)
  • some constants defined specifically for each type:
    • TOTAL_SIZE – gives the total number of bits of the internal type; e.g. for r32, it's 32 bits (note: not currently defined in code)
    • FRACTION_SIZE – gives the size of the fraction field

Everything else (including other necessary constants) should be derivable from the ones above.

1011X avatar Feb 11 '19 01:02 1011X