Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sprintF

Status
Not open for further replies.

vadg

Technical User
Joined
Mar 4, 2007
Messages
9
assuming integer and decimal values

if I use sprintF to limit the number of decimals

my integers are displayed as decimals (2.00, e.g)

any way to limit sprintF's use and exclude integers?
 
Not automatically.

Just add logic to determine which of your numbers are integers, and purposefully give them different formatting.

Code:
my $format = ($number = int $number) ? "%d" : "%.2f";

- Miller
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top