Cobol: Refactor gmath.cc 'int256' structure.
Refactors Cobol's `int256` structure to include `rdigits` for fixed-point arithmetic.
This commit refactors the int256 structure used in libgcobol’s gmath.cc for fixed-point arithmetic. The rdigits member, representing the number of digits to the right of the decimal point, is now integrated into the structure itself. This change simplifies operations by carrying the scale information with the number, reducing the need for separate scale management logic in functions like addition, subtraction, and multiplication.
In Details
The int256 structure in libgcobol/gmath.cc, previously used for fixed-point arithmetic, has been modified to include an rdigits member. This change centralizes scale information within the structure, impacting numerous arithmetic and assignment functions (scale_int256_by_digits, add_int256_to_int256, multiply_int128_by_int128, etc.) that now implicitly use this embedded scale.
- int256
- A data structure representing a 256-bit integer, used in the Cobol runtime library for handling large numbers in fixed-point arithmetic.
- rdigits
- Represents the number of digits to the right of the decimal point in a fixed-point number.
- fixed-point arithmetic
- Arithmetic operations on numbers where the position of the decimal point is fixed and does not change.
- gmath.cc
- A source file within the libgcobol library containing mathematical functions.