Integer Data Type
The
Integer
Data type holds a whole numerical value from -9007199254740991 to 9007199254740991 (for number values involving decimals, please see
Decimal
)
Conditionals
TODO (see common conditionals - what are those?)
Operations
Inc
The
Inc
operation will increment or add one to the value of the target integer.
<dcs.Var Name="TestVar1" Type="Integer" SetTo="12" />
<dcs.With Target="$TestVar1">
<Inc />
</dcs.With>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is 13
Dec
Inversely, the
Dec
operation will decrement or subtract one off the value of the target integer.
<dcs.Var Name="TestVar1" Type="Integer" SetTo="12" />
<dcs.With Target="$TestVar1">
<Dec />
</dcs.With>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is 11
Set
The
Set
operation will override and replace the current value of the target integer.
<dcs.Var Name="TestVar1" Type="Integer" SetTo="12" />
<dcs.With Target="$TestVar1">
<Set Value="15" />
</dcs.With>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is 15
Add
The
Add
operation will add the amount defined in the
Value
attribute to the target Integer.
<dcs.Var Name="TestVar1" Type="Integer" SetTo="12" />
<dcs.With Target="$TestVar1">
<Add Value="15" />
</dcs.With>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is 27
Subtract
The
Subtract
operation will subtract the amount defined in the
Value
attribute to the target Integer.
<dcs.Var Name="TestVar1" Type="Integer" SetTo="12" />
<dcs.With Target="$TestVar1">
<Subtract Value="15" />
</dcs.With>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is -3
Multiply
The
Multiply
operation will multiply the amount defined in the
Value
attribute by the target Integer.
<dcs.Var Name="TestVar1" Type="Integer" SetTo="12" />
<dcs.With Target="$TestVar1">
<Multiply Value="3" />
</dcs.With>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is 36
Divide
The
Divide
operation will divide the amount defined in the
Value
attribute by the target Integer.
<dcs.Var Name="TestVar1" Type="Integer" SetTo="12" />
<dcs.With Target="$TestVar1">
<Divide Value="3" />
</dcs.With>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is 4
This operation can also make use of a variety of modes inherited from Java programming language rounding modes using the
Mode
attribute. (Please see this
link
for more detailed documentation and examples of the modes.) The available modes are:
UP
DOWN
CEILING
FLOOR
HALF_UP
HALF_DOWN
HALF_EVEN
UNNECESSARY
<dcs.Var Name="TestVar1" Type="Integer" SetTo="12" />
<dcs.With Target="$TestVar1">
<Divide Value="5" Mode="FLOOR" />
</dcs.With>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is 2
Min
The
Min
operation compares the the current integer value with the integer defined in the
Value
attribute and assigns the integer with the smaller of the two.
<dcs.Var Name="TestVar1" Type="Integer" SetTo="12" />
<dcs.With Target="$TestVar1">
<Min Value="9" />
</dcs.With>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is 9
Max
The
Max
operation compares the the current integer value with the integer defined in the
Value
attribute and assigns the integer with the larger of the two.
<dcs.Var Name="TestVar1" Type="Integer" SetTo="12" />
<dcs.With Target="$TestVar1">
<Max Value="19" />
</dcs.With>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is 19
Abs
The
Abs
operation sets the integer to its absolute value.
<dcs.Var Name="TestVar1" Type="Integer" SetTo="-12" />
<dcs.With Target="$TestVar1">
<Abs />
</dcs.With>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is 12
Random
The
Random
operation generates a random number between the values defined in the
From
and
To
attributes.
Please note that the
From
value is inclusive to the random number generated, but the
To
value is exclusive. For example, to generate a number from 1 to 10, the values of
<Random From="1" To="11" />
should be used, as
<Random From="1" To="10" />
would only produce 1 through 9.
This operation has two versions. The default operation generates a random number in a longer process that is cryptographically secure. If a random number is needed that is not security sensitive, the
Quick
attribute can be added and set to true.
<dcs.Var Name="TestVar1" Type="Integer">
<Random From="6" To="24" />
</dcs.Var>
<dc.Out>TestVar1 is {$TestVar1}</dc.Out>
Output:
TestVar1 is 22Example with Quick Mode:
<dcs.Var Name="TestVar11" Type="Integer">
<Random From="6" To="24" Quick="true" />
</dcs.Var>
<dc.Out>TestVar11 is {$TestVar11}</dc.Out>
Output:
TestVar1 is 23