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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

modulus operator

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Is this typical behaviour for the perl modulus operator? I assume it's something to do with the size of the number.

#!/usr/local/bin/perl -w

use strict;

print abs(-6767389730); #this prints 6767389730
print "\n";
print abs(-6767389730) % 10; #this prints 5 !
print "\n";
 
i don't know where you are testing, but the moduilus prints 0 on my machine..


the % operator is supposed to give you the remainder of the first number divided by the second.
 
try doing $var = abs(-6767389730) % 10;
then print $var;

% may be a string modifier. You shouldn't do math in a print statement anyway.
Sincerely,

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

Part and Inventory Search

Sponsor

Back
Top