adds

Add two signed integers, checking for overflow.

The overflow is sticky, meaning a sequence of operations can be done and overflow need only be checked at the end.

  1. int adds(int x, int y, ref bool overflow)
    nothrow @safe @nogc pure pragma(inline, true)
    int
    adds
    ()
    (
    int x
    ,
    int y
    ,
    ref bool overflow
    )
  2. long adds(long x, long y, ref bool overflow)
  3. cent adds(cent x, cent y, ref bool overflow)

Parameters

x
Type: int

left operand

y
Type: int

right operand

overflow
Type: bool

set if an overflow occurs, is not affected otherwise

Return Value

Type: int

the sum

Suggestion Box / Bug Report