Re: converting to FLOATING_POINT..
- From: perlicious@xxxxxxxxx (Rex Rex)
- Date: Wed, 17 Aug 2005 11:14:02 -0400
Replace,
$time = ($time * 2.0);
to
$time = sprintf("%0.2f", ($time * 2));
That should do it.
perldoc -f sprintf
-- Rex
On 8/17/05, Vineet Pande <pande_vineet@xxxxxxxxxxx> wrote:
> Hi:
>
> In the following piece of script, I would like to convert the $time after *
> by 2.0 to floating point, for instance i want 0*2 to be printed as 0.0; How
> to do that?
>
>
> if ($_ =~ ( /TEMP/ ))
>
> {
>
> my $time = (substr($_, 30, 14));
> $time =~ s/\s//g;
> my $temp = (substr($_, 53, 10));
> $temp =~ s/\s//g;
> $time = ($time * 2.0);
> $time = ?????????????????#convert to floatpoint
> foreach ($time)
> {
> print OUT $time ;
> print OUT " ";
> foreach ($temp) {
> print OUT $temp;
> print OUT "\n";
> }
> }
>
> }
>
>
> cheerio
> vineet
>
> _________________________________________________________________
> FREE pop-up blocking with the new MSN Toolbar - get it now!
> http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
> For additional commands, e-mail: beginners-help@xxxxxxxx
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
.
- Follow-Ups:
- Re: converting to FLOATING_POINT..
- From: Vineet Pande
- Re: converting to FLOATING_POINT..
- References:
- converting to FLOATING_POINT..
- From: Vineet Pande
- converting to FLOATING_POINT..
- Prev by Date: converting to FLOATING_POINT..
- Next by Date: Re: require and true value
- Previous by thread: converting to FLOATING_POINT..
- Next by thread: Re: converting to FLOATING_POINT..
- Index(es):
Relevant Pages
|