Hi -

the perl function "int" does not round,
so something like:

if (int ($a * 1_000_000) == int ($b * 1_000_000)) {...}

should shift each 6 pos left, truncate the fraction,
and do the comparision (untested).

Aloha => Beau.

-----Original Message-----
From: John W. Krahn [mailto:krahnj@;acm.org]
Sent: Tuesday, October 22, 2002 1:28 PM
To: [EMAIL PROTECTED]
Subject: Re: truncation of decimal places.


Naveen Prabhakar wrote:
>
> Hi,

Hello,

> 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.


s/(?<=\.\d{6})\d+// for $a, $b;

if ( $a eq $b ) {



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to