Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Want to Truncate A Number... NOT round it

by metadoktor (Hermit)
on Feb 11, 2004 at 20:34 UTC ( #328376=note: print w/replies, xml ) Need Help??


in reply to Want to Truncate A Number... NOT round it

#!/usr/local/bin/perl -w use strict; my $n = 34.57889; my $d = 4; # Num of right hand digits to grab my ($lhs,$rhs) = split /\./,sprintf("%f",$n),2; $n = join '.',$lhs,substr($rhs,0,$d); print "$n\n";

metadoktor

"The doktor is in."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://328376]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2019-07-15 19:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?