CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Floating point

 



lost
Deleted

Jan 31, 2001, 9:20 AM

Post #1 of 2 (186 views)
Floating point Can't Post

I am still trying to learn perl and need some guidance from an expert.

I want to do some simple math in the script like division 10/3. How can I limit the answer to just 2 decimal points like 3.33 instead of 3.3333333333???
Please advise.

$a = 10;
$b = 3;
$c = $a/$b;

THNX in advance.




izzy
stranger

Jan 31, 2001, 10:42 AM

Post #2 of 2 (184 views)
Re: Floating point [In reply to] Can't Post

try this:
$c = sprintf("%0.2f", $a/$b);


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives