|
|
| Syntactic Confectionery Delight | |
| PerlMonks |
Re: Padding with sprintf changing numberby Marshall (Canon) |
| on Sep 24, 2021 at 21:36 UTC ( [id://11137002]=note: print w/replies, xml ) | Need Help?? |
|
As another thought for you...consider the use of functions in the POSIX module to specify exactly what you want. Of interest: "ceil", "floor", "lround", "modf", "round", "trunc". Some of the these functions didn't appear until Perl 5.22. So the newer functions could be an issue if you have an old Perl. Also read the documentation carefully. Some of these functions return an actual integer. Some return a float with the fractional part set to zero. These functions should be pretty fast (at least they are in C). In some cases, it might be appropriate to call one of these functions to make it crystal clear to the reader your exact intent even though you might follow it with some kind of printf or sprintf.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||