Pecunia
Safe & Easy Currency Library
Description
Pecunia is designed to be an easy-to-use C++ currency library that provides robust handling of monetary values and currency operations. Unlike using primitive types like long double, which can lead to precision errors and rounding issues, Pecunia implements fixed-point decimal arithmetic specifically designed for financial calculations. It provides built-in support for ISO-4217 currency codes, automatic currency conversion, and guaranteed protection against overflow/underflow errors. Compared to other currency libraries, Pecunia offers additional guard precision in all operations, comprehensive currency symbol support, and flexible rounding options while maintaining a simple, intuitive API.
Stable Version 0.9.0
Packages of the current stable version are listed below, or check out the stable release branch using Mercurial .
Features
- All mathematical operations are guaranteed to not overflow nor underflow.
- The represented amount has extra guard precision built into all operations.
- Has all the currency codes in the ISO-4217 standard .
- Has all the currency currency symbols of common currencies.
- Automatic conversions between currencies. With support for custom currency converters.
- Support for common high-level mathematical operations, e.g. summation, absolute value, etc.
- Built-in common rounding functions with support for custom ones as well.
Example
Below is an illustration of adding two items purchased and storing their sum into a single variable.
Money
pop{Currency::USD
, 1, 25};Money
candy{Currency::USD
, 0, 75};Money
sum{pop + candy};// Sum holds 2 USD.
More complex examples and explanations are available on the Wiki .
Known Issues
- The stream insertion operator do not restore original state after execution.
- The stream extraction operator do not restore original state after execution.
Report Issues
If you have an issue, enhancement, or wish that you would like to let me know. Please submit your report and I'll address it.
Downloads & Packages
Operating system specific packages and installers are available below. Select the download that most matches your computer and desired installation wishes.
Binary
Select a download below to have a runnable version installed. All binary
packages are signed using this
FSF key
.
The signatures can be verified using
GNU Privacy Guard
.
Type | Debian | Fedora | macOS | Mageia | Raspberry Pi OS | Windows |
---|---|---|---|---|---|---|
Executable Runtime | Package — Hash — Signature | Package — Hash — Signature | Universal Installer — Hash — Signature | Package — Hash — Signature | Package — Hash — Signature | Installer — Hash — Signature |
Development | Package — Hash — Signature | Package — Hash — Signature | Available within the installer. | Package — Hash — Signature | Package — Hash — Signature | Available within the installer. |
Source
Select the download below to have the source code extracted onto your computer.
Development
You can track the development version by using Mercurial on the default branch .
Repository hosting is generously provided by Octobus and Clever cloud .