GDC adds intrinsic support for core.checkedint
tsbockman via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 2 13:24:54 PDT 2015
On Thursday, 2 July 2015 at 11:26:24 UTC, Robert burner Schadek
wrote:
> On Thursday, 2 July 2015 at 00:29:46 UTC, rsw0x wrote:
>> all bitwise ops except for shifting are fundamental math
>> operators just like addition and subtraction if you view an
>> integer as a bitstring(which is what it is...)
>
> I must have missed something in my math classes.
>
> "Like the natural numbers, Z is closed under the operations of
> addition and multiplication" [1]
>
> build in Integer are not really closed, but close enough.
> No mentioning of shift operations though.
>
> [1] https://en.wikipedia.org/wiki/Integer
I don't see why the closed-ness of the integers under an
operation should determine whether it makes the cut or not, but
if that's the standard:
The built-in integer types are truly closed under the bitwise
operators `~`, `&`, `|`, and `^`, with no overflow, underflow, or
undefined combinations.
In contrast, unary `-` can overflow, while binary `+`, `-`, and
`*` can all overflow or underflow.
`<<` and `>>` are not closed, but they are conceptually identical
to `* 2^^` and `/ 2^^`, respectively. Their invalid input
combinations can be handled the same way.
More information about the Digitalmars-d
mailing list