BloombergLP::bdldfp::DecimalConvertUtil::decimal64ToMultiWidthEncodingRaw

Encode decimal into buffer if it fits in 5 or fewer bytes.

Synopsis

Declared in <bdldfp_decimalconvertutil.h>

static
bsls::Types::size_type
decimal64ToMultiWidthEncodingRaw(
    unsigned char* buffer,
    bdldfp::Decimal64 decimal);

Description

If the specified decimal can be encoded in 5 or fewer bytes of the multi-width encoding format, then store decimal into the specified buffer in that format, and return the number of bytes written to buffer. Otherwise, return 0. The behavior is undefined unless buffer points to a memory area having at least 5 bytes. Note that this function does not supporting encoding values requiring a full IEEE network encoding, which is supported by the decimal64ToMultiWidthEncoding function.

Return Value

number of bytes written, or 0 if encoding needs more than 5

Parameters

NameDescription
bufferreceives the multi-width encoding
decimalvalue to encode