Pecunia 0.9.0-alpha.22
Library using the ISO-4217 currency standard & a fixed monetary unit size
Loading...
Searching...
No Matches
pecunia::rounders::currency Namespace Reference

Functions

PECUNIA_EXPORT MajorUnit down (const MajorUnit &amount, const std::uint8_t &minorDigits, const std::uint8_t &digitsLeft)
 Performs a rounding operation using the round-half down towards -∞ method.
 
PECUNIA_EXPORT MajorUnit even (const MajorUnit &amount, const std::uint8_t &minorDigits, const std::uint8_t &digitsLeft)
 Performs a rounding operation using the round-half to even method.
 
PECUNIA_EXPORT MajorUnit none (const MajorUnit &amount, const std::uint8_t &minorDigits, const std::uint8_t &digitsLeft)
 Performs no rounding operation.
 
PECUNIA_EXPORT MajorUnit up (const MajorUnit &amount, const std::uint8_t &minorDigits, const std::uint8_t &digitsLeft)
 Performs a rounding operation using the round-half up towards +∞ method.
 

Function Documentation

◆ down()

PECUNIA_EXPORT MajorUnit pecunia::rounders::currency::down ( const MajorUnit & amount,
const std::uint8_t & minorDigits,
const std::uint8_t & digitsLeft )
nodiscard

Performs a rounding operation using the round-half down towards -∞ method.

Parameters
amountThe major and minor units of the currency stored as one.
minorDigitsThe number of digits in the minor unit.
digitsLeftThe number of digits left in the minor unit after rounding the number to the right of the decimal point.
Returns
The rounded number with the correct number of digits.

◆ even()

PECUNIA_EXPORT MajorUnit pecunia::rounders::currency::even ( const MajorUnit & amount,
const std::uint8_t & minorDigits,
const std::uint8_t & digitsLeft )
nodiscard

Performs a rounding operation using the round-half to even method.

Parameters
amountThe major and minor units of the currency stored as one.
minorDigitsThe number of digits in the minor unit.
digitsLeftThe number of digits left in the minor unit after rounding the number to the right of the decimal point.
Returns
The rounded number with the correct number of digits.

◆ none()

PECUNIA_EXPORT MajorUnit pecunia::rounders::currency::none ( const MajorUnit & amount,
const std::uint8_t & minorDigits,
const std::uint8_t & digitsLeft )
nodiscard

Performs no rounding operation.

Parameters
amountThe major and minor units of the currency stored as one.
minorDigitsIgnored.
digitsLeftIgnored.
Returns
The rounded number as supplied.

◆ up()

PECUNIA_EXPORT MajorUnit pecunia::rounders::currency::up ( const MajorUnit & amount,
const std::uint8_t & minorDigits,
const std::uint8_t & digitsLeft )
nodiscard

Performs a rounding operation using the round-half up towards +∞ method.

Parameters
amountThe major and minor units of the currency stored as one.
minorDigitsThe number of digits in the minor unit.
digitsLeftThe number of digits left in the minor unit after rounding the number to the right of the decimal point.
Returns
The rounded number with the correct number of digits.