On 7/18/06, Tim Lucia <[EMAIL PROTECTED]> wrote:
> -----Original Message-----
> From: Obed Soto Déctor [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 17, 2006 7:28 PM
> To: [email protected]
> Subject: problem with double data
>
> Hi, i'm sorry for my english, i'm from México and i'm gonna do my best,
>
> i've made a store procedure but i have some problems becouse when a
> make a simple operation with double datas the result is not what i
> wait.
>
> look
>
> cantidad_origen = 30.5
> cantidad_ = 30.4
> suma = 0
>
> UPDATE detalle_tanque set cantidad = ( cantidad_origen - cantidad_ -
> suma ) where id_detalle_transaccion = id_detalle_transaccion_origen
> and ctl_no=ctl_no_origen;
>
> cantidad = 0.100000000000001
>
Looks like your standard floating-point rounding error. See
http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html which
says: "A double-precision floating-point number is accurate to
approximately 15 decimal places." If I counted right, the "errant 1" at the
end is in place 15, so that is accurate to approximately 15 places.
Tim
OOOHHH !!! thank's
you're right, thanks, i did this, i dont know if it's ok.
DECLARE nueva_cantidad DOUBLE(10,4);
and then i use it
SET nueva_cantidad = ( cantidad_origen -
cantidad_ - suma );
UPDATE detalle_tanque set cantidad =
nueva_cantidad where id_detalle_transaccion =
id_detalle_transaccion_origen and ctl_no=ctl_no_origen;
SET nueva_cantidad = cantidad_ - suma;
INSERT INTO detalle_tanque VALUES ( id_ ,
ctl_no_origen ,id_tanque_destino_, nueva_cantidad );
and it works ok now.. !!!
it's ok what i've done ? !!!!
thank's in advanced
--
http://www.obed.org.mx ---> blog
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]