Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

multiple of 10

multiple of 10

multiple of 10

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.


RE: multiple of 10

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


pattern match it like this....

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


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

 keep the rudder amid ship and beware the odd typo

RE: multiple of 10

Use the modulus (remainder of a division)

if ($num % 10 == 0) {$multiple = true;}

Tom Anderson
CEO, Order amid Chaos, Inc.

RE: multiple of 10

thanks a lot for your help.

RE: multiple of 10

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?

RE: multiple of 10

x % y returns the remainder of x / y.

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

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

Tom Anderson
CEO, Order amid Chaos, Inc.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close