Skip site navigation (1) Skip section navigation (2)

Re: postgres arithmetic: raising to nth power

From: Ennio-Sr <nasr(dot)laili(at)tin(dot)it>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: postgres arithmetic: raising to nth power
Date: 2005-09-30 00:05:59
Message-ID: 20050930000559.GB8506@deby.ei.hnet (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
* Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> [290905, 18:27]:
> Ennio-Sr <nasr(dot)laili(at)tin(dot)it> writes:
> > So, the problem is: how can I get to know which results are correct and
> > which aren't?  May be the presence on the trailing 'e+..' is signalling
> > there is an error?
> I take it you've never seen floating-point notation before?
> Read the "e" as "times ten to the power of".
> 			regards, tom lane

Touche' .... :-)

Of course, I did see floating-point notation before, but that doesn't
mean I recalled how I should interpret it .... ;)
[I left school many, many, many, many, many years ago and could not find
my old financial maths book yet!]

Back to my problem, rivisited at the light of your (formerly obscure to me ;) )

1 - select 100*(1.10)^1277    
2 - select (1.10)^1277  
I should have noticed the difference in the 'trailing numbers' ... but I
was diverted by other problems .....;( 


[To better answer Andrej's question:]

# Suppose I invest one dollar at a 10% compound rate for a period of 3
# years; at the end I should get :

 select (1+.10)^3 

# Now the reverse: what is the IRR on my investment considered that I
# got  $ 1.331 after a 3 years period? 

 select (1.331)^(1/3::float)-1 

# or, to get a finer result:

 select to_char( (1.331)^(1/3::float)-1,'9999.0000' ) 
(1 row)

Thanks again.

[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo.   \\?//
 Fa' qualche cosa di cui non sei capace!"  (diceva Henry Miller) ]    (°|°)
[Why use Win$ozz (I say) if ... "even a fool can do that.              )=(
 Do something you aren't good at!" (as Henry Miller used to say) ]

In response to

pgsql-novice by date

Next:From: Greg Sabino MullaneDate: 2005-09-30 00:34:45
Subject: Re: perl DBI::Pg metacharacter \i com_list.sql
Previous:From: Ennio-SrDate: 2005-09-29 23:26:27
Subject: Re: postgres arithmetic: raising to nth power

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group