Re: Arbitrary precision arithmatic with pgsql

Поиск
Список
Период
Сортировка
От Jan Wieck
Тема Re: Arbitrary precision arithmatic with pgsql
Дата
Msg-id 41349568.6020400@Yahoo.com
обсуждение исходный текст
Ответ на Re: Arbitrary precision arithmatic with pgsql  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
On 8/31/2004 11:04 AM, Tom Lane wrote:

> Jan Wieck <JanWieck@Yahoo.com> writes:
>> I agree that doing
>>      select 2::numeric ^ 100;
>> should emit some sort of a warning.
> 
> I do not.  The conversion of 2::numeric to float is exact, so AFAICS
> the only way to do that would be to make *every* coercion of numeric to
> float emit a warning.  This is not a reasonable response to the fact
> that Rajesh is unaware of the set of available operators.  Moreover
> it would essentially break float constants (since "2.0" starts life
> as numeric and is only cast to float when the context demands).

I thought they start life as an unknown literal ... that of course 
changes things.


Jan

> 
> I'd be in favor of adding a numeric^numeric operator to ease access to
> the existing pow() code, but I'm not sure this makes the issue go away
> entirely.  It looks like "select 2 ^ 100" would still default to being
> a float operation.
> 
> regression=# create operator ^ (procedure=pow, leftarg=numeric, rightarg=numeric);
> CREATE OPERATOR
> regression=# select 2::numeric ^ 100;
>                      ?column?
> --------------------------------------------------
>  1267650600228229401496703205376.0000000000000000
> (1 row)
> 
> regression=# select 2 ^ 100;
>        ?column?
> ----------------------
>  1.26765060022823e+30
> (1 row)
> 
> regression=# select 2.0 ^ 100;
>                      ?column?
> --------------------------------------------------
>  1267650600228229401496703205376.0000000000000000
> (1 row)
> 
> 
>             regards, tom lane


-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Arbitrary precision arithmatic with pgsql
Следующее
От: Manuel Sugawara
Дата:
Сообщение: Re: colored PL with emacs