Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 4th, 1999, 12:46 PM
bag
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
anyone know how to round unsing perl. I need to truncate my price to the nearest cent. I need to format the output as a dollar price. I know how to add the dollar sign, I need to make it so I always have two decimal places.

Reply With Quote
  #2  
Old December 7th, 1999, 05:13 AM
Imo
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
perldoc -f printf

printf("%.f2n",$var);

Try that or something like it.

Reply With Quote
  #3  
Old December 16th, 1999, 05:23 AM
AjayLulia
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I have a Best way in which u will get acrute result:

I have used some thing like this
Connect to any backend database for Eg ORACLE, use this Statement
"Select round($varname) from dual"
and then fetch the row.

you will get Proper result.

The other way is to use MATH Module
Available with perl check in lib directory.

I think this will help u

------------------
Ajay Lulia.


Reply With Quote
  #4  
Old December 22nd, 1999, 09:20 PM
bag
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
got it working.

$formattedTotal=sprintf("$%.2f",$totalPX);

that did the trick. It added a $ to the front and truncated to the nearest cent.

thanks for your help everyone.

Reply With Quote
  #5  
Old December 28th, 1999, 01:38 PM
Imo
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
depends how accurate you want to be I guess!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > rounding numbers

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap