Skip to content

DecimalMark

Which character an amount's text uses as the decimal point: the dot or the comma.

"1.234" is a fraction just over one to an American and one thousand two hundred and thirty-four to most of Europe. Nothing in the text itself can settle it — so the money readers ask you, with a DecimalMark parameter. Whichever character you name as the decimal point, the other one becomes the digit-grouping character (the thousands separator) and is checked as such: a value written in the wrong notation is rejected, never silently misread as a different number.

Members

Member Meaning
Dot The dot is the decimal point; commas group digits: "1,234.56". The US and invariant habit. This is the default.
Comma The comma is the decimal point; dots group digits: "1.234,56". Most of Europe.

Where it is used

The money readers on CkMoney — Amount, AmountOrNull, Format, MinorUnits, Round and Split — all take a mark parameter. The default for every one of them is the dot (CkSettings.DefaultDecimalMark).

Quick look

using SafeCoder.CommonKit;
using SafeCoder.CommonKit.Enums;

CkMoney.Amount("1,234.56");           // -> 1234.56  (the dot is the default)

CkMoney.Amount("1.234,56");           // -> 0  (wrong notation: rejected, never misread)

CkMoney.Amount(
    input: "1.234,56",
    mark: DecimalMark.Comma
);                                    // -> 1234.56