Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Datatype Double: Comma or Dot as Separator?

Tags:

mysql

double

In a MySql Table i have a column with datatype double. There are two ways of displaying a decimal Number: Comma and Dot.

I've tried both and both seem to work. But I'd like to ask which of those two versions is "more" correct?

21.6

or

21,6

(Didn't find anything in the MySql documentation).

like image 819
Jbartmann Avatar asked Dec 20 '25 19:12

Jbartmann


2 Answers

From the Number Literals manual page:

Integers are represented as a sequence of digits. Floats use “.” as a decimal separator. Either type of number may be preceded by “-” or “+” to indicate a negative or positive value, respectively

Dot has been used as decimal separator in almost every computer language since Cobol.

Using comma does not work:

mysql> SELECT 21.6;
+------+
| 21.6 |
+------+
| 21.6 |
+------+
1 row in set (0.14 sec)

mysql> SELECT 21,6;
+----+---+
| 21 | 6 |
+----+---+
| 21 | 6 |
+----+---+
1 row in set (0.00 sec)
like image 118
Álvaro González Avatar answered Dec 22 '25 09:12

Álvaro González


I think you need to double check your numbers. As far as i know and as far as i can tell they havent changed this. The decimal point seprator for mysql is "." and the thousand seprator is ",".

Your best bet if you want to change this is to check the users formating when you display it to them. You cant change how its stored in the database.

like image 40
DaImTo Avatar answered Dec 22 '25 11:12

DaImTo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!