Naveen Prabhakar wrote:
>
> Hi,
>
> I have a really simple question.I have two numbers
>
> say $a = 1.559999
>
> $b=1.5599999999
>
> how do I compare them to exactly 6 decimals without doing a round off.I
> used sprintf but it does a round off.
>
i don't know why you would want to do that but perhaps something like:
#!/usr/bin/perl -w
use strict;
my $i = 1.99994544;
my $j = 1.999944;
if($i =~ /^([+-]?\d+\.\d{6})/ && $1 == $j){
print "$i($1) == $j\n";
}else{
print "$i != $j\n";
}
__END__
the above won't work if there is no decimal or the number format is
different, say it's in the scientific notation such as 1.9e8, etc.
david
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]