error update

I have a field in type of float(20,2),
the value is 158059.45, i want to update to 158059.46,
but it can't update.
and there are some update have the same problem like,
158059.01 will become 158059.02
158059.04 will become 158059.05
158059.07 will become 158059.06
158059.10 will become 158059.09
158059.13 will become 158059.12

can you help me with this problem?


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs [at] m.gmane.org
leong [ Mi, 13 August 2003 04:29 ] [ ID #76179 ]

Re: error update

Multiply both operands by 100
Do the Multiplication
Divide the result by .0001
Regards,
-M
----- Original Message -----
From: "leong" <seekl [at] tm.net.my>
To: <bugs [at] lists.mysql.com>
Sent: Tuesday, August 12, 2003 7:29 PM
Subject: error update


> I have a field in type of float(20,2),
> the value is 158059.45, i want to update to 158059.46,
> but it can't update.
> and there are some update have the same problem like,
> 158059.01 will become 158059.02
> 158059.04 will become 158059.05
> 158059.07 will become 158059.06
> 158059.10 will become 158059.09
> 158059.13 will become 158059.12
>
> can you help me with this problem?
>
>
> --
> MySQL Bugs Mailing List
> For list archives: http://lists.mysql.com/bugs
> To unsubscribe: http://lists.mysql.com/bugs?unsub=mgainty [at] hotmail.com
>
>

--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs [at] m.gmane.org
Martin Gainty [ Mi, 13 August 2003 07:52 ] [ ID #76180 ]

Re: error update

Hi,

leong wrote:
> I have a field in type of float(20,2),
> the value is 158059.45, i want to update to 158059.46,
> but it can't update.
> and there are some update have the same problem like,
> 158059.01 will become 158059.02
> 158059.04 will become 158059.05
> 158059.07 will become 158059.06
> 158059.10 will become 158059.09
> 158059.13 will become 158059.12
>
> can you help me with this problem?

There is no problem. This is consequence of using floating point arithmetic where
values are never precise. 0.1 for example can be represented as 0.99999999

Conisder using DECIMAL or use some rounding.

Best regards

--
Are you MySQL certified? -> http://www.mysql.com/certification
For technical support contracts, visit https://order.mysql.com/?ref=msal
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Alexander Keremidarski <salle [at] mysql.com>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer
/_/ /_/\_, /___/\___\_\___/ Sofia, Bulgaria
<___/ www.mysql.com




--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs [at] m.gmane.org
Alexander Keremidarsk[1] [ Mi, 13 August 2003 09:01 ] [ ID #76183 ]
Datenbanken » gmane.comp.db.mysql.bugs » error update

Vorheriges Thema: Password() generates random result in 4.1.0 alpha
Nächstes Thema: UPDATE statement