postgres arithmetic: raising to nth power
От | Ennio-Sr |
---|---|
Тема | postgres arithmetic: raising to nth power |
Дата | |
Msg-id | 20050929193657.GA5327@deby.ei.hnet обсуждение исходный текст |
Ответы |
Re: postgres arithmetic: raising to nth power
Re: postgres arithmetic: raising to nth power |
Список | pgsql-novice |
[Using postgres (PostgreSQL) 7.4.7 on GNU/Linux 2.4.27-1-386 - Debian/Sarge] ---------------------------------------- Hi all, testing a few arithmetic calculations to make sure I understood how they worked before including them in a a query I met with the following results: select 100*1.10^1277/365::float: # supposedly: first calculates 1.10^1277 ---------------------------------- # then multiplies by 100 and divide by 365 1.97772581606028e+52 (1 row) # Let's see if my guess is correct: select 100*(1.10)^1277 ---------------------- 7.21869922862002e+54 (1 row) select 7.21869922862002/365 ----------------------------- 0.01977725816060279452 (1 row) # Hmmm: same result, except there is no multiplication by 100! select 7.21869922862002/365::float ------------------------------------ 0.0197772581606028 (1 row) # the presence of either float or numeric dowsn't alter the result. select 100*(1.10)^1277::float ------------------------------- 7.21869922862002e+54 (1 row) # However, using more reasonable numbers: select (1.10)^12 ------------------ 3.138428376721 (1 row) select 100*(1.10)^12 ---------------------- 313.8428376721 (1 row) the result is correct. ------------------------------------- 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? Could somebody give me a short explanation or suggest further readings? Thanks for your attention. 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 по дате отправления: