phpbar.de logo

Mailinglisten-Archive

[php] OT: MySQL internes Runden

[php] OT: MySQL internes Runden

Andreas Ahlenstorf lists at ahlenstorf.ch
Fre Jun 15 10:07:46 CEST 2007


Am 15.06.2007 um 09:32 schrieb Michael Borchers:

> Bsp.:
> 6.45*12.04 = 77,658
>
> Leider rundet MySQL direkt auf 77.66.

Sicher?

mysql> SELECT VERSION();
+------------+
| VERSION()  |
+------------+
| 5.0.37-log |
+------------+
1 row in set (0.00 sec)

mysql> DESCRIBE test;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| eins  | decimal(4,2) | NO   |     |         |       |
| zwei  | decimal(4,2) | NO   |     |         |       |
+-------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> SELECT *, `eins` * `zwei` FROM test;
+------+-------+-----------------+
| eins | zwei  | `eins` * `zwei` |
+------+-------+-----------------+
| 6.45 | 12.04 |         77.6580 |
+------+-------+-----------------+
1 row in set (0.00 sec)

mysql> SELECT `eins` * 12.04 FROM test;
+----------------+
| `eins` * 12.04 |
+----------------+
|        77.6580 |
+----------------+
1 row in set (0.01 sec)

mysql> SELECT `eins` * '12.04' FROM test;
+------------------+
| `eins` * '12.04' |
+------------------+
|           77.658 |
+------------------+
1 row in set (0.02 sec)

Also, bei mir kommen die Sachen richtig raus.

Gruss,
A.



php::bar PHP Wiki   -   Listenarchive