Sums of floating point numbers
Posted in 1998
Topics: Installation, Setup & Upgrades, Stored Procedures & SPL, Data Types & Schema Design
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. 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