Re: Help with Stupid question
- From: tom@xxxxxxxxxxxxxx (Tom Phoenix)
- Date: Sat, 15 Jul 2006 15:21:31 -0700
On 7/15/06, Ralph H. Stoos Jr. <rstoos@xxxxxxxxxxxxxxxx> wrote:
I want to know if / how the $buf/25400 part can
be formatted to be a number with only two or three decimal places.
In Perl, that kind of formatting is generally done with printf or its
related function sprintf. Where sprintf is a function which returns a
formatted string, printf goes a step further and prints the string.
They're documented in perlfunc, but this example may be all you need:
my $result = sprintf "%.3f", $buf/25400;
Hope this helps!
--Tom Phoenix
Stonehenge Perl Training
.
- Follow-Ups:
- RE: Help with Stupid question
- From: Timothy Johnson
- RE: Help with Stupid question
- References:
- Help with Stupid question
- From: Ralph H. Stoos Jr.
- Help with Stupid question
- Prev by Date: Help with Stupid question
- Next by Date: Re: Help with Stupid question
- Previous by thread: Help with Stupid question
- Next by thread: RE: Help with Stupid question
- Index(es):
Relevant Pages
|
|