List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:September 7 2001 4:06pm
Subject:Re: Floats
View as plain text  
This is a standard 1st quarter computer science topic.
You can't reliably test floating point numbers for equality.
0.1 has no exact floating point binary representation.
Perhaps you should use the DECIMAL type which is stored
internally as a string.

Guddack Thorsten ICM MP SCM SCCM PI wrote:

> Hi List,
> 
> I'm a little bit confused.
> 
> I do the following:
> 
> Create a table with 1 int and two floats.....
> 
> mysql> create table testfloat(z int, ll float, ul float);
> Query OK, 0 rows affected (0.00 sec)
> 
> inserting one row into the table........
> 
> mysql> insert into testfloat values(1,-0.1,0.1);
> Query OK, 1 row affected (0.00 sec)
> 
> check if values where inside........
> 
> mysql> select * from testfloat;
> +------+------+------+
> | z    | ll   | ul   |
> +------+------+------+
> |    1 | -0.1 |  0.1 |
> +------+------+------+
> 1 row in set (0.01 sec)
> 
> 
> and now I wants to take a look on special rows......
> 
> mysql> select * from testfloat where ul=0.1;
> Empty set (0.00 sec)
> 
> 
> I didn't understand why I didn't get what I expect.
> 
> Best regards
> 
> Thorsten Guddack
> 
> ---------------------------------------------------------------------
> 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 <mysql-thread84908@stripped>
> To unsubscribe, e-mail
> <mysql-unsubscribe-gerald_clark=suppliersystems.com@stripped>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-- 
Gerald L. Clark
gerald_clark@stripped

Thread
FloatsGuddack Thorsten ICM MP SCM SCCM PI7 Sep
  • Re: FloatsGerald Clark7 Sep