22 Votes

Lazarus: Change Decimal Separator (Dot and Comma)

Question by Guest | Last update on 2021-07-07 | Created on 2014-12-12

Sometimes, I am writing floating-point numbers and numerical values having decimal places with a point, sometimes with a comma. So, for example 1.23 or 1,23.

However, Lazarus only seems to understand the separation with a dot, it is not accepting comma values as input.

How can I teach Lazarus to be able to work with the comma as decimal separator as well?

ReplyPositiveNegative
2Best Answer2 Votes

In Lazarus, there is the global variable or setting DefaultFormatSettings > DecimalSeparator. This is determining which character (char) is used as decimal separator.

It is possible to change the settings like that:

// point as decimal separator
DefaultFormatSettings.DecimalSeparator := '.';

// comma as decimal separator
DefaultFormatSettings.DecimalSeparator := ';';

// arbitrary character as decimal separator
DefaultFormatSettings.DecimalSeparator := '|';

Depending on which number input you are expecting, you can set the decimal separator with DecimalSeparator to a point, a comma or any other random character.

PS: Using DefaultFormatSettings.ThousandSeparator instead, you can change the character that is used as thousand separator between 3 numbers for better readability, if you want to change this, too.
Last update on 2021-07-07 | Created on 2014-12-14

ReplyPositive Negative
Reply

Related Topics

VirtualBox: Change Date and Time

Tutorial | 10 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.