Decimal.fromStringWithThousandsSeparatorImpl

Handle thousand separators for non exponential numbers.

struct Decimal(size_t maxSize64)
bool
fromStringWithThousandsSeparatorImpl
(
C
bool allowSpecialValues = true
bool allowStartingPlus = true
bool allowLeadingZeros = true
)
(
scope const(C)[] str
,,,,
int exponentShift = 0
)
if (
isSomeChar!C
)
if (
maxSize64 &&
maxSize64 <= ushort.max
)

Return Value

Type: bool

false in case of overflow or incorrect string.

Examples

Decimal!3 decimal;
DecimalExponentKey key;

assert(decimal.fromStringWithThousandsSeparatorImpl("12,345.678", ',', '.', key));
assert(cast(double) decimal == 12345.678);
assert(key == DecimalExponentKey.dot);

assert(decimal.fromStringWithThousandsSeparatorImpl("12,345,678", ',', '.', key, -3));
assert(cast(double) decimal == 12345.678);
assert(key == DecimalExponentKey.none);

assert(decimal.fromStringWithThousandsSeparatorImpl("021 345,678", ' ', ',', key));
assert(cast(double) decimal == 21345.678);
assert(key == DecimalExponentKey.dot);

Meta