# Integer Operands

Integer operands are created either by creating integer variables (which are the simplest integer operands) or by using operand properties that produce integer operands.

#### Examples of Integer Operands

The simplest integer operands, integer variables, can be created using `Mixin#int_var`. The method takes one argument, the domain of the integer variable. The domain represents the values that the variable can take. A variable with domain 0..9 can for instance take any value in the range 0 to 9.

```int_operand = int_var(0..9) # Creates an integer variable with domain 0..9.
```

A couple of examples of properties that produce integer operands include the `IntOperand#+` property, which produces a new integer operand representing the sum of two integer operands:

```new_int_operand = int_operand1 + int_operand2
```

The `IntEnumOperand#max` property produces a new integer operand representing the maximum value of the integer operands in an enumeration:

```new_int_operand = int_enum.max
```

## Constraints

Generated from `IntConstraintReceiver`.

### `==`

`==(int_operand_or_fixnum, options = {})`

Constrains the integer operand to equal `int_operand_or_fixnum`. #equal and #equal_to are aliases of this method.

##### Examples
```# +int1+ must equal +int2+
int1.must == int2

# +int+ must equal 17
int.must == 17

# +int1+ must equal +int2+. We reify the constraint with
# +bool+ and select +domain+ as strength.
int1.must.equal(int2, :reify => bool, :strength => :domain)
```

### `>`

`>(int_operand_or_fixnum, options = {})`

Constrains the integer operand to be strictly greater than `int_operand_or_fixnum`. #greater and #greater_than are aliases of this method.

##### Examples
```# +int1+ must be strictly greater than +int2+
int1.must > int2

# +int+ must be strictly greater than 17
int.must > 17

# +int1+ must be strictly greater than +int2+. We reify the
# constraint with +bool+ and select +domain+ as strength.
int1.must_be.greater_than(int2, :reify => bool, :strength => :domain)
```

### `>=`

`>=(int_operand_or_fixnum, options = {})`

Constrains the integer operand to be greater than or equal to `int_operand_or_fixnum`. #greater_or_equal and #greater_than_or_equal_to are aliases of this method.

##### Examples
```# +int1+ must be greater than or equal to +int2+
int1.must >= int2

# +int+ must be greater than or equal to 17
int.must >= 17

# +int1+ must be greater than or equal to +int2+. We reify the
# constraint with +bool+ and select +domain+ as strength.
int1.must.greater_or_equal(int2, :reify => bool, :strength => :domain)
```

### `<`

`<(int_operand_or_fixnum, options = {})`

Constrains the integer operand to be strictly less than `int_operand_or_fixnum`. #lesser and #lesser_than are aliases of this method.

##### Examples
```# +int1+ must be strictly less than +int2+
int1.must < int2

# +int+ must be strictly less than 17
int.must < 17

# +int1+ must be strictly less than +int2+. We reify the
# constraint with +bool+ and select +domain+ as strength.
int1.must_be.less_than(int2, :reify => bool, :strength => :domain)
```

### `<=`

`<=(int_operand_or_fixnum, options = {})`

Constrains the integer operand to be less than or equal to `int_operand_or_fixnum`. #less_or_equal and #less_than_or_equal_to are aliases of this method.

##### Examples
```# +int1+ must be less than or equal to +int2+
int1.must <= int2

# +int+ must be less than or equal to 17
int.must <= 17

# +int1+ must be less than or equal to +int2+. We reify the
# constraint with +bool+ and select +domain+ as strength.
int1.must.less_or_equal(int2, :reify => bool, :strength => :domain)
```

### `in`

`in(domain, options = {})`

Creates a domain constraint using the specified domain, specified as an enumeration of integers. The integer operand is constrained to take a value in the domain. Domains should be specified as ranges if possible.

##### Examples
```# +x+ must be in the range 1..10
x.must_be.in 1..10

# +x+ must not be in the range -5...5
x.must_not_be.in -5...5

# Specifies the above, but reifies the constraint with the boolean
# operand +bool+ and specified +value+ as strength.
x.must_not_be.in(-5...5, :reify => bool, :strength => :value)

# +x+ must be in the enumeration [3,5,7].
x.must_be.in [3,5,7]

# +x+ must not be in the enumeration [5,6,7,17].
x.must_not_be.in [5,6,7,17]

# Specifies the above, but reifies the constraint with the boolean
# operand +bool+ and specified +value+ as strength.
x.must_not_be.in([5,6,7,17], :reify => bool, :strength => :value)
```

## Properties

Generated from `IntOperand`.

### `+`

`+(int_operand_or_fixnum)`

Produces a new IntOperand representing this operand plus `int_operand_or_fixnum`.

##### Examples
```# +int1+ plus +int2+
int1 + int2

# +int+ plus 17
int + 17
```

### `-`

`-(int_operand_or_fixnum)`

Produces a new IntOperand representing this operand minus `int_operand_or_fixnum`.

##### Examples
```# +int1+ minus +int2+
int1 - int2

# +int+ minus 17
int - 17
```

### `*`

`*(fixnum)`

Produces a new IntOperand representing this operand times a constant.

##### Examples
```# +int+ times 17
int * 17
```

`*(int_operand)`

Produces a new IntOperand representing this operand times `int_operand`.

##### Examples
```# The value of +int_op1+ times +int_op2+.
int_op1 * int_op2
```

### `abs`

`abs()`

Produces an IntOperand representing the absolute value of this operand.

##### Examples
```# The absolute value of +int_op+.
int_op.abs
```

### `square_root`

`square_root()`

Produces an IntOperand representing the square root of this operand rounded down.

##### Examples
```# The square root of +int_op+, rounded down.
int_op.square_root
```

### `squared`

`squared()`

Produces an IntOperand representing this operand squared.

##### Examples
```# The value of +int_op*int_op+.
int_op.squared
```