How to test a value, or number, to see if it is a multiple of, say, X?


#1

Hi,
How would you test a number to see if its a multiple of another number?

I want to test of, say, widget.x is a multiple of, say 100, or not.

Thanks!


#2

Use the modulo operator in your condition to test for the remainder after division:

If widget.x % 100 equals 0

Some examples:

512 % 100 == 12
400 % 100 == 0
10 % 100 == 10

#3

Most excellent, thank you for the swift reply!


closed #4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.