develooper Front page | perl.beginners | Postings from September 2009

numeric comparison always returning true!

Thread Next
September 24, 2009 11:05
numeric comparison always returning true!
Message ID:
I have a script that tells me the largest file (in bytes) for each
extension.  I store the largest size in a hash, keyed by the extension.

The numeric comparison portion is clearly not working, since it is returning true every time regardless of the numbers being compared.  Here's a snippet, along with the output shown:

if ( $bytes > $sizes{$ext}->{largest} ) {
    print "$bytes is larger than $sizes{$ext}->{largest_size}\n";
    $sizes{$ext}->{largest_size} = $bytes;
else {
    print "$bytes is smaller than $sizes{$ext}->{largest_size}\n";
304785408 is larger than 
407666688 is larger than 304785408
595656704 is larger than 407666688
597778432 is larger than 595656704
568844288 is larger than 597778432
157255680 is larger than 568844288
512342016 is larger than 157255680
616058880 is larger than 512342016
728705024 is larger than 616058880
6008832 is larger than 728705024

Notice that last line?  Am I missing something obvious, or is there
something wrong here?


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About