Home
Search Perl pages
Subjects
By activity
Professions, Sciences, Humanities, Business, ...
User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...
Text Strings
Conversions, tests, processing, manipulation,...
Math
Integer, Floating point, Matrix, Statistics, Boolean, ...
Processing
Algorithms, Memory, Process control, Debugging, ...
Stored Data
Data storage, Integrity, Encryption, Compression, ...
Communications
Networks, protocols, Interprocess, Remote, Client Server, ...
Hard World Timing, Calendar and Clock, Audio, Video, Printer, Controls...
File System
Management, Filtering, File & Directory access, Viewers, ...
|
|
|
While use integer provides integer-only arithmetic, there is no similar ways to provide
rounding or truncation at a certain number of decimal places. For rounding
to a certain number of digits, sprintf() or
printf() is usually the easiest route.
The
POSIX module (part of the standard perl distribution) implements ceil(), floor(), and a number of other mathematical and trigonometric functions. The Math::Complex module (part of the standard perl distribution) defines a number of mathematical functions that can also work on real numbers. Math::Complex not as efficient as
POSIX, but
POSIX can't work with complex numbers.
Rounding in financial applications can have serious implications, and the
rounding method used should be specified precisely. In these cases, it
probably pays not to trust whichever system rounding is being used by Perl,
but to instead implement the rounding function you need yourself.
|
|