use double with specific precision.... like

create table b (id double (5, 3));

then:

insert into b values (1.123, 3.14);

and then

select * from b where id > 1.123;
shows only one record (3.14).

select * from b where id < 1.123;
empty set.

select * from b where id = 1.123;
returns a result table with one record 1.123.

 

---------- "Octavian Rasnita" <[EMAIL PROTECTED]> writes:

Return-Path: <[EMAIL PROTECTED]>
Received: from mx09.lax.untd.com (mx09.lax.untd.com [10.130.24.69])
        by maildeliver04.nyc.untd.com with SMTP id AAA9DCAFXAKM8WJA
        for <[EMAIL PROTECTED]> (sender 
<[EMAIL PROTECTED]>);
        Fri, 24 Jan 2003 04:00:37 -0500 (EST)
Received: from web.mysql.com (web.mysql.com [213.136.49.183])
        by mx09.lax.untd.com with SMTP id AAA9DCAFWAP7ZG5J
        for <[EMAIL PROTECTED]> (sender 
<[EMAIL PROTECTED]>);
        Fri, 24 Jan 2003 01:00:36 -0800 (PST)
Received: (qmail 11889 invoked by uid 7797); 24 Jan 2003 04:49:19 -0000
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm (http://www.ezmlm.org)
List-ID: <mysql.mysql.com>
Precedence: bulk
List-Help: <mailto:[EMAIL PROTECTED]>
List-Unsubscribe: <mailto:[EMAIL PROTECTED]>
List-Post: <mailto:[EMAIL PROTECTED]>
List-Subscribe: <mailto:[EMAIL PROTECTED]>
Delivered-To: mailing list [EMAIL PROTECTED]
Received: (qmail 11871 invoked from network); 24 Jan 2003 04:49:19 -0000
Message-ID: <002901c2c364$59877270$[EMAIL PROTECTED]>
From: "Octavian Rasnita" <[EMAIL PROTECTED]>
To: "Stefan Hinz, iConnect \(Berlin\)" <[EMAIL PROTECTED]>,
        "MySQL" <[EMAIL PROTECTED]>
References: <006101c2c09a$9c0f7330$[EMAIL PROTECTED]> 
<01e601c2c0ce$1a5cf1d0$dc4fc7d9@mephisto>
Subject: Re: Is it normal?
Date: Thu, 23 Jan 2003 22:13:07 +0200
MIME-Version: 1.0
Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

And does anyone know what column type I should use if I want a precise
calculation?
I've even tried with text and blob, but they are not working either.
Only the int type is precise?

Thanks.

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

----- Original Message -----
From: "Stefan Hinz, iConnect (Berlin)" <[EMAIL PROTECTED]>
To: "Octavian Rasnita" <[EMAIL PROTECTED]>; "MySQL" <[EMAIL PROTECTED]>
Sent: Monday, January 20, 2003 11:42 PM
Subject: Re: Is it normal?


Octavian,

> mysql> create table test(id float);
> mysql> insert into test values(1.123), (3.1495);
> mysql> select * from test where id=1.123;
> Empty set (0.00 sec)
> Shouldn't this last query show me the record that has the id=1.123?

Well ... 1.123 is greater than 1.123, see:

mysql> select id from octavian where id > 1.123;
+--------+
| id     |
+--------+
|  1.123 |
| 3.1495 |
+--------+
2 rows in set (0.00 sec)

Now here's why. Floats are simply not precise:

mysql> select id*10000 from octavian where id > 1.123;
+-----------------+
| id*10000        |
+-----------------+
| 11230.000257492 | <----------
| 31494.998931885 |
+-----------------+
2 rows in set (0.00 sec)

> What query should I use to do this?

I leave this one to Paul or one of the other gurus.

Regards,
--
  Stefan Hinz <[EMAIL PROTECTED]>
  Gesch䦴sfí±£í²¥r / CEO iConnect GmbH <http://iConnect.de>
  Heesestr. 6, 12169 Berlin (Germany)
  Tel: +49 30 7970948-0  Fax: +49 30 7970948-3

----- Original Message -----
From: "Octavian Rasnita" <[EMAIL PROTECTED]>
To: "MySQL" <[EMAIL PROTECTED]>
Sent: Monday, January 20, 2003 9:34 AM
Subject: Is it normal?


> Hi all,
>
> I've tried the following SQL queries:
>
> mysql> create table test(id float);
> Query OK, 0 rows affected (0.00 sec)
>
> mysql> insert into test values(1.123), (3.1495);
> Query OK, 2 rows affected (0.01 sec)
> Records: 2  Duplicates: 0  Warnings: 0
>
> mysql> select * from test where id=1.123;
> Empty set (0.00 sec)
>
> Shouldn't this last query show me the record that has the id=1.123?
>
> What query should I use to do this?
>
> Thank you.
>
>
>
> Teddy,
> Teddy's Center: http://teddy.fcc.ro/
> Email: [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php






---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to