Re: postgres arithmetic: raising to nth power

Поиск
Список
Период
Сортировка
От Ennio-Sr
Тема Re: postgres arithmetic: raising to nth power
Дата
Msg-id 20050930000559.GB8506@deby.ei.hnet
обсуждение исходный текст
Ответ на Re: postgres arithmetic: raising to nth power  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
* Tom Lane <tgl@sss.pgh.pa.us> [290905, 18:27]:
> Ennio-Sr <nasr.laili@tin.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) ]

В списке pgsql-novice по дате отправления:

Предыдущее
От: Ennio-Sr
Дата:
Сообщение: Re: postgres arithmetic: raising to nth power
Следующее
От: "Greg Sabino Mullane"
Дата:
Сообщение: Re: perl DBI::Pg metacharacter \i com_list.sql