in reply to Re: Re: Re: Rounding to a Given Number of Significant Figures Rather Than Decimal Places
in thread Rounding to a Given Number of Significant Figures Rather Than Decimal Places

Sorry to be a bit dim but, with the following lines of code:
$_ = FormatSigFigs($_,8); my $clem = sprintf("%08g", $_); print "$clem\n";
and the number 1298.844667 as input, I get the output 01298.84 and not 1298.845, which is what I want.
Any ideas?
Thanks again for your help.

Edit: larsen. Added <code> tags and some minor formatting.

  • Comment on Re: Re: Re: Re: Rounding to a Given Number of Significant Figures Rather Than Decimal Places
  • Select or Download Code