Logo Search packages:      
Sourcecode: icu version File versions

U_STABLE double U_EXPORT2 ucurr_getRoundingIncrement ( const UChar *  currency,
UErrorCode ec 
)

Returns the rounding increment for the given currency, or 0.0 if no rounding is done by the currency.

Parameters:
currency null-terminated 3-letter ISO 4217 code
ec input-output error code
Returns:
the non-negative rounding increment, or 0.0 if none, or 0.0 if there is an error ICU 3.0

Definition at line 1423 of file ucurr.cpp.

References U_INVALID_FORMAT_ERROR, and U_SUCCESS.

                                                                  {
    const int32_t *data = _findMetaData(currency, *ec);

    // If the meta data is invalid, return 0.0.
    if (data[0] < 0 || data[0] > MAX_POW10) {
        if (U_SUCCESS(*ec)) {
            *ec = U_INVALID_FORMAT_ERROR;
        }
        return 0.0;
    }

    // If there is no rounding, return 0.0 to indicate no rounding.  A
    // rounding value (data[1]) of 0 or 1 indicates no rounding.
    if (data[1] < 2) {
        return 0.0;
    }

    // Return data[1] / 10^(data[0]).  The only actual rounding data,
    // as of this writing, is CHF { 2, 5 }.
    return double(data[1]) / POW10[data[0]];
}


Generated by  Doxygen 1.6.0   Back to index