Welcome ppeel,
This may be my experience only, but I've had problems keeping leading zeros ('0'), in a variable ( especially hashes and arrays ) within a long running script. So instead of using 'sprintf', I usually add a number with the correct number of zeros, and then use 'substr' to remove it when I need to print, etc. So your:
becomes for me:$nfc_amt = sprintf("%07f", $nfc_amt);
Then when I need to print/etc. the result, I do:$nfc_amt = $nfc_amt + 10000000; # or $nfc_amt += 10000000;
I have only experienced this when I add the zeros and then use the variables much later. YMMV. (Note: It also could have been a bug in the version of Perl that I was using which is now fixed. :-)print "NFC_AMT after adding zeroes: ",substr($nfc_amt,1),"\n";
Regards...Ed
"Well done is better than well said." - Benjamin Franklin
In reply to Re: sprintf() returning incorrect value
by flexvault
in thread sprintf() returning incorrect value
by ppeel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |