This is a discussion on Re: Result precision and scale for decimal arithmetic expression and within the Informix forums, part of the Database Server Software category; --> Here is your answer which you can also find by using ESQL/C program to describe the query and then ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Here is your answer which you can also find by using ESQL/C program to describe the query and then use PRECISION and SCALE arguments to see the resultant type (How do we do that ... you can find that in ESQL/C manual.) > > decimal(p1, s1)+decimal(p2, s2) Resultant Precision : (p1>p2 ? p1+1 : p2+1) Resultant Scale : (s1>s2 ? s1 : s2) > > decimal(p1, s1)-decimal(p2, s2) Resultant Precision : (p1>p2 ? p1+1 : p2+1) Resultant Scale : (s1>s2 ? s1 : s2) > > decimal(p1, s1)*decimal(p2, s2) Resultant Precision : p1+p2 Resultant Scale : s1+s2 > > decimal(p1, s1)/decimal(p2, s2) Resultant Precision : p1+p2 Resultant Scale : 255 But ofcourse, if any of the addition or addition by 1 leads the value to the greater value than supported then it is rounded to the max value supported. Thanks and Regards, Gaurav lanegroups@go.com (Lan Huang) To: informix-list@iiug.org Sent by: cc: owner-informix-li Subject: Re: Result precision and scale for decimal arithmetic expression and st@iiug.org aggregate function 06/30/03 04:42 PM Please respond to lanegroups Decimals are different from floating point numbers. Decimals are still considered a precise data type like integers, so the scale is important. I'd like to have a fomula of the precision and scale of the result types. Thanks! Fernando Nunes <spam@domus.online.pt> wrote in message news:<bdkkd0$sc70v$1@ID-161111.news.dfncis.de>... > Lan Huang wrote: > > I'd like to know what's the result precision and scale of the decimal > > arithmentic expression and aggregate function. > > > > For example, what's the result type of > > decimal(p1, s1)+decimal(p2, s2) > > decimal(p1, s1)-decimal(p2, s2) > > decimal(p1, s1)*decimal(p2, s2) > > decimal(p1, s1)/decimal(p2, s2) > > AVG(decimal(p1, s1)) > > etc > > > > It will also be nice if someone tell me which documentation describes > > the result types of the expressions and functions. > > > > Thanks, > > Lan > > Don't take this as a definitive answer but: > > - The precision of any floating point data type can vary with the > architecture. The are numbers wich cannot be represented exactly in some > standard representations. > > You can find some information in the SQL Reference Guide > > Regards sending to informix-list |