Is there a way of checking that a value is wholly divisible by another number, for example 1000 divided by 100 would be true, but 1115 divided by 100 would be false?
I am tring to
Any help would be much appreciated :-)
Is there a way of checking that a value is wholly divisible by another number, for example 1000 divided by 100 would be true, but 1115 divided by 100 would be false?
I am tring to
Any help would be much appreciated :-)
You can use the %
-operator:
bool isDivisible = 1115 % 100 == 0;
The % operator computes the remainder after dividing its first operand by its second. All numeric types have predefined remainder operators.
You can use mod operator (%
) and check that remainder is equal to 0:
var result = (1000.00 % 100) == 0; // evaluates to true
var result = (1115.00 % 100) == 0; // evaluates to false