Unix Technical Forum

Re: Result precision and scale for decimal arithmetic expression and

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 ...


Go Back   Unix Technical Forum > Database Server Software > Informix

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 06:05 PM
Fnu Gaurav
 
Posts: n/a
Default Re: Result precision and scale for decimal arithmetic expression and






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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:40 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com