[J3] [BULK] Re: Upcoming gfortran 15 will contain an implementation of unsigned numbers
Thomas König
tk at tkoenig.net
Thu Oct 17 17:07:06 UTC 2024
Am 16.10.24 um 01:30 schrieb Malcolm Cohen via J3:
> Well, I beg to differ on the " manual detection of overflow would be
> impossible if" assertion. That is not the case. The detection code >
is different, that's all.
Agreed, then.
>
> But manual detection is not the issue, as one would hardly decorate
> every addition with manual detection code.
This is possible by wrapping a modulo 2^n unsigned type in a derived
type, and then define operations for it, with checking dependent on a
parameter. This would be somewhat tedious to write (I would probably
do it with a script), but would only need to be done once. Legibility
of the main source code would not be impeded.
A legitimate worry would be the efficiency of calling a user-defined
function, but this should be less of a worry with link-time
optimization.
The modulo 2^n unsigned arithmetic can be considered a foundation
upon which all other desired behavior (checking, wrapping) can be built
by the user.
If any of the other behaviors would be prescribed in the standard, this
would not be possible.
Best regards
Thomas
More information about the J3
mailing list