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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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 ;) )
'clarification':

1 - select 100*(1.10)^1277
----------------------
7.21869922862002e+54
^^
2 - select (1.10)^1277
----------------------
7.21869922862002e+52
^^
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
-----------------
1.331

# 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
-------------------------------
0.1

# or, to get a finer result:

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

Thanks again.
Regards,
Ennio.

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

Browse pgsql-novice by date

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