Basic Arithmetic Operations on Integers
Explore basic arithmetic operations on integers in D programming, including increment, decrement, addition, subtraction, multiplication, division, remainder, and power operations. Understand how overflow affects integer values and how truncation occurs during division. Gain foundational knowledge to correctly manipulate integer data types in D.
We'll cover the following...
We will take advantage of the .min and .max properties below, which we have seen in the fundamental types lesson. These properties provide the minimum and maximum values that an integer type can have.
Increment: ++
This operator uses a single operand (usually a variable or an expression) and is written before the name of that variable. It increments the value of that variable by 1:
As the program’s output shows, the value of number has been updated.
New value: 11
The increment operator is the equivalent of using the += (add-and-assign) operator with a value of 1:
number += ...