[Db] Mysql e calcoli in virgola mobile
Tinazzi Matteo
matteo a xelefant.com
Gio 11 Gen 2007 17:53:28 CET
Davide Michel 'ZioBudda' Morelli wrote:
>> Ciao all. Ho una tabella utenti con un campo U cosi' definito:
>>
>> `U` float NOT NULL default '0',
>>
>> Ora guardate cosa seccede:
>>
>> mysql> update Utenti set U = 0;
>> Query OK, 1 row affected (0.00 sec)
>> Rows matched: 29 Changed: 1 Warnings: 0
>>
>> mysql> update Utenti set U = 0.01 where id_u = 141;
>> Query OK, 1 row affected (0.00 sec)
>> Rows matched: 1 Changed: 1 Warnings: 0
>>
>> mysql> select U from Utenti where id_u = 141;
>> +------+
>>> U |
>> +------+
>>> 0.01 |
>> +------+
>> 1 row in set (0.00 sec)
>>
>> mysql> select MAX(U) from Utenti;
>> +--------------------+
>>> MAX(U) |
>> +--------------------+
>>> 0.0099999997764826 |
>> +--------------------+
>> 1 row in set (0.00 sec)
>>
>>
>> Che qualcuno mi spieghi cosa combina MySQL. Anche perche' mi sballa
>> tutti i conti cosi' facendo.
>>
>> M.
>>
la spiegazione precisa non la ricordo ma si tratta di problemi di
arrotondamenti, piuttosto che il tipo float usa il decimal che salva il
valore come stringa
>> --
>> Michel 'ZioBudda' Morelli michel a ziobudda.net
>> Consulenza sistemistica in ambito OpenSource.
>> Sviluppo applicazioni web dinamiche (LAMP+Ajax)
>> Telefono: +39-0240706096 -- Fax: +39-0291390660
>> Cellulare: +39-3939890025
>>
>> http://www.ziobudda.net ICQ: 58351764
>> http://www.ziobuddalabs.it Skype: zio_budda
>> http://www.ajaxblog.it
>>
>>
>
>
>
> _______________________________________________
> Db mailing list
> Db a lists.ziobudda.net
> http://lists.ziobudda.net/mailman/listinfo/db
------------------------------------
Tinazzi Matteo
X-Elefant Software s.r.l.
Via Treviso 61/13 31057 Silea (Treviso)
ICQ# 71-883-066
------------------------------------
Maggiori informazioni sulla lista
Db