in reply to 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
Another way to test for the decimal point, if you wanted to be purely math-based, could be if ($num == round($num)).my $num = 12345.678; # a total of 9 characters if (length $num > 8) { if ($num =~ /\./) # If there's a decimal point { # Put it to seven significant figures } else { # Put it to eight significant figures } }
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re4: Rounding to a Given Number of Significant Figures Rather Than Decimal Places
by Hofmator (Curate) on Jan 13, 2003 at 16:53 UTC | |
by dragonchild (Archbishop) on Jan 13, 2003 at 18:30 UTC |