Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple of 10

Status
Not open for further replies.

tonyjob

Programmer
Nov 20, 2000
25
0
0
GB
if i had a number in a variable how could i check it to see if its a multiple of 10 (10,20,140,900,etc..) i figure if i divide the number by 10 and it makes a whole number it will be a multiple, but how could i check the number to see if it is a whole number?

any help or comments will be apreciated.

~Tony
 
use the 'int' function to see if you have a decimal portion

or

pattern match it like this....

if ($num =~ /\.\d/) { print "I contain a decimal followed by a digit.\n"; }

or

ponder.....ponder....... TMTOWTDI




keep the rudder amid ship and beware the odd typo
 
tanderso,
could you please give me a bit more info about modulus.

what would this return: 100 % 10
would it be 0 or would it be an error?
and would this work: $mod = 100 % 10
would $mod = null, empty, or 0?
 
x % y returns the remainder of x / y.

100/10=10 with a remainder of 0, so
100%10=0

yes, you can set $mod = 100 % 10... it will equal 0.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top