Hi Wijaya Edward -
  
At 2005-10-19, 21:18:16 you wrote:
>
>> Hi:
>
>Hi
>> For example, for $j=2.56789, how can I get the very first two digits
>> after points,ie, I just want to get 2.56.
>> Thank you very much in advance.
>> 
>
>Is this what you want?
>
>$ perl -e '$j = 2.56789; $j =~ /(\d\.\d\d)+/; $ns = $1; print "$ns\n";'
>prints: 2.56

That's what you said you wanted...
However if you want to round, try sprintf( or printf ):

 $j=2.56789;
 $roundedj = sprintf "%4.2f", $j;

$roundedj is 2.57.
  
>
>Read: perldoc perlretut.
>Hope that helps
>
>--
>Regards,
>Edward WIJAYA
>SINGAPORE
>
>
>-- 
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
><http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
>
>-- 
>No virus found in this incoming message.
>Checked by AVG Anti-Virus.
>Version: 7.0.344 / Virus Database: 267.12.4/143 - Release Date: 10/19/2005
>


                        
Aloha => Beau;
[EMAIL PROTECTED]
2005-10-19



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to