codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  strange Perl problem with printf vs. sprintf  elliottbecker at 21:04 on Friday, November 02, 2007
 

So I am having this problem where when I try to use printf to output a number with a single decimal place it tacks on an extra 0, but when I use sprintf to load the value into a variable then print out that variable it works fine. Below is the working code, I didn't save the non-working code:

$val = ($offices{$office}{'opened'} / $offices{$office}{'sent'}) * 100;
$val = sprintf ("%.1f", $val);
print OUTPUTFILE"$val\t";

Thanks








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Is it possible to use A7Soft JExamXML with Crimson.
•  strange Perl problem with printf vs. sprintf
•  Re: perl script help needed
•  help me in setting background image in perl
•  Re: help me
•  Net::ftp->login problem
•  Timer
•  Double execution problem in .Net
•  saving??


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007