error update

error update

am 13.08.2003 04:29:53 von leong

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@m.gmane.org

Re: error update

am 13.08.2003 07:52:59 von Martin Gainty

Multiply both operands by 100
Do the Multiplication
Divide the result by .0001
Regards,
-M
----- Original Message -----
From: "leong"
To:
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@hotmail.com
>
>

--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org

Re: error update

am 13.08.2003 09:01:26 von Alexander Keremidarski

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
/ /|_/ / // /\ \/ /_/ / /__ 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@m.gmane.org