[Bioperl-l] perl question

Andreas Kahari ak at ebi.ac.uk
Mon Nov 5 12:43:06 UTC 2007


On Mon, Nov 05, 2007 at 05:50:04PM +0530, neeti somaiya wrote:
> Again a perl question, and maybe a very trivial one.
> How do I terminate a number like 3.1232010098 to only 3 decimal places in
> perl?

When displaying:

  printf( "The number is %.3f\n", $number );

When making a string:

  my $string = sprintf( "%.3f", $number );


BTW, this is cutting, not rounding.


Cheers,
Andreas


-- 
Andreas Kähäri :: Ensembl Software Developer
European Bioinformatics Institute (EMBL-EBI)
--------------------------------------------



More information about the Bioperl-l mailing list