comparing decimal numbers

From: Thens (thens_at_NOSPAMti.com)
Date: 04/30/04


Date: Fri, 30 Apr 2004 23:54:08 +0530

Hi,

I have to compare two decimals numbers 1.5.0 and 2.1.1. The trouble is they originate from string. Hence I get warnings that say
" Argument "1.5.0" isn't numeric in numeric ge" ...

This is my code;

...
( $rel1, $rel2 ) = ( 'r1.5.0', 'r2.1.1' );
s/^r// for ( $rel1, $rel2 );
return $rel1 > $rel2 ? 1 : 0

Please let me know if Iam missing something here.

For the moment I did this to overcome the error message.

...
( $rel1, $rel2 ) = ( 'r1.5.0', 'r2.1.1' );
s/^r// for ( $rel1, $rel2 );
$rel1++; $rel2++; # to avoid the non numeric warnings
return $rel1 >= $rel2 ? 1 : 0

Thanks in advance for your help.

Regards,
Thens.



Relevant Pages