At 03:50 PM 6/19/2007 -0700, John Townsend wrote:
>I don't need to round the number, I just want it to drop everything
>after the 6th decimal point. This should be easy, but I'm drawing a
>blank.

If u really need to truncate it and can't use sprintf for some reason u can
do this.

sub trunc {
        my ($num, $places) = @_;
        my ($int, $frac) = split /\./, $num;
        return $num if length $frac == $places;
        if ($places > length $frac) {
                $frac .= "0" x $places;
        }
        $frac = substr $frac, 0, $places;
        return "${int}.${frac}" if $frac;
        return $int;
}
###########
print trunc 11.23456, 4;
print "\n";
print trunc 5.6, 3;
^D
11.2345
5.600





--
REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
"...ne cede malis"

00000100

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to