![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 5 of 5 total |
![]() |
Mon, Sep 24 2007 3:22 AM | Permanent Link |
Dave Bailey | Hi,
I have a table with 4 Float Fields eg: a,b,c,d d is entered by the user but is the result of a+b+c I wanted to create an SQL to filter out all records where d<>a+b+c I used SELECT * FROM MyTable WHERE (a+b+c)<>d But the result included records where a+b+c=d as well? Tested the same on Access and no problem. Maybe it is something I am doing wrong? Thanks |
Mon, Sep 24 2007 4:06 AM | Permanent Link |
Eryk Bottomley | Dave,
> I have a table with 4 Float Fields eg: a,b,c,d > > d is entered by the user but is the result of a+b+c > > I wanted to create an SQL to filter out all records where d<>a+b+c > > I used SELECT * FROM MyTable WHERE (a+b+c)<>d Never use direct equality tests on floats like that. > But the result included records where a+b+c=d as well? Try "WHERE ABS((a+b+c)-d) > 0.01" ...or whatever level of precision makes sense in the context of your app. Eryk PS: You might want to read up on BCD fields - they may be more appropriate than floats if you are doing stuff like this. |
Mon, Sep 24 2007 4:08 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | Dave
Float fields are notorious for this. Its a case of what you see is not necessarily what you get ![]() Roy Lambert |
Mon, Sep 24 2007 6:42 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Roy,
<< Float fields are notorious for this. Its a case of what you see is not necessarily what you get ![]() Then again Tim may need to make sure the results for a float field are only returned to the precision specified. I'm not sure which it should be in ElevateDB, in DBISAM it was definitely your responsibility. >> ElevateDB is the same as DBISAM in this regard. -- Tim Young Elevate Software www.elevatesoft.com |
Mon, Sep 24 2007 6:43 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Eryk,
<< PS: You might want to read up on BCD fields - they may be more appropriate than floats if you are doing stuff like this. >> DECIMAL is the proper term with ElevateDB. ![]() http://www.elevatesoft.com/edb1sql_exact_numeric_types.htm -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Monday, July 7, 2025 at 06:35 PM | Privacy Policy![]() © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |