Re: Sums of floating point numbers
Posted in 1998
In article <68eo7v$5ta@cssun.mathcs.emory.edu>, Don_Jordan <Don_Jordan@fpm.uchicago.edu> writes >Hi everyone, > >I'm very new to this list and almost as new to Informix, as my question >will no doubt demonstrate. I've searche the FAQ for an answer, but didn't >see anything that appeared relevant. > >We are currently running ISQL 4.10 on SCO UNIX System V/386 Release 3.2 >(with plans to upgrade both). I am trying to sum a floating point field in >a view, and seem to have run into the problem that Informix only seems to >want to sum money, i.e., 2 decimal places. My data frequent has 3 or more >preceeding zeros, e.g., 0.0001, so all significance in the sum is lost. > I have just added a section to the FAQ, try the environment variable DBFLTMASK=6. >Without reconfiguring the data, it is easy to overcome loss of significance >by a simple device such as "sum_field = sum(field*1000000.0)/1000000.0". >However, the resultant data type still appears to be DECIMAL(x.2). When >trying to display this on a screen form, I can overcome the loss of display >precision when doing a LOOKUP by equating sum_field to a displayonly field >of type FLOAT. However, the displayonly field will not correctly change >when doing queries on multiple entry detail tables, i.e., it would >correctly display the sum_field value for only the first entry in the query >of the detail table. > >My manual states that aggregate functions take on the data type of the >underlying table fields, but this appears untrue. Is there a clean way to >wok around this problem? > >Thanks in advance for any help on this, Don > >Don Jordan >The University of Chicago >Office of Radiation Safety >Zoology Building Room 11 >1101 East 57th Street >Chicago, Illinois 60637 >Tel. 773-702-6299 >Fax 773-702-4008 >email Don_Jordan@fpm.uchicago.edu > -- David Williams Maintainer of the Informix FAQ Primary site (Beta Version) http://www.smooth1.demon.co.uk Official site http://www.iiug.org/techinfo/faq/faq_top.html I see you standin', Standin' on your own, It's such a lonely place for you, For you to be If you need a shoulder, Or if you need a friend, I'll be here standing, Until the bitter end... So don't chastise me Or think I, I mean you harm... All I ever wanted Was for you To know that I care