Re: [HACKERS] Problems on NUMERIC

Поиск
Список
Период
Сортировка
От Thomas G. Lockhart
Тема Re: [HACKERS] Problems on NUMERIC
Дата
Msg-id 367FB3C6.35A67006@alumni.caltech.edu
обсуждение исходный текст
Ответ на Problems on NUMERIC  (jwieck@debis.com (Jan Wieck))
Ответы Re: [HACKERS] Problems on NUMERIC  (jwieck@debis.com (Jan Wieck))
Список pgsql-hackers
>     First I wonder why the can_coerce... stuff is  #if'd  out  of
>     parse_relation.c?

Oh! That looks like my style of #if FALSE, but I can't recall why it is
that way. Will look at it. Does it work to just substitute an #if TRUE?
Perhaps I had it disabled during debugging, but...

>     How  do  other  databases  handle  this  problem.  How is the
>     precision of a numeric result defined?

I've enclosed some snippets from my SQL92 2nd Draft Standard doc. It
gives you a lot of latitude :)
                    - Tom
 Syntax Rules
 1) If the data type of both operands of a dyadic arithmetic opera- tor is exact numeric, then the data type of the
resultis exact numeric, with precision and scale determined as follows:
 
 a) Let S1 and S2 be the scale of the first and second operands    respectively.
 b) The precision of the result of addition and subtraction is    implementation-defined, and the scale is the maximum
ofS1    and S2.
 
 c) The precision of the result of multiplication is implementation-    defined, and the scale is S1 + S2.
 d) The precision and scale of the result of division is    implementation-defined.

<snip large amounts>
 Whenever an exact or approximate numeric value is assigned to a data item or parameter representing an exact numeric
value,an approximation of its value that preserves leading significant dig- its after rounding or truncating is
representedin the data type of the target. The value is converted to have the precision and scale of the target. The
choiceof whether to truncate or round is implementation-defined.
 
 An approximation obtained by truncation of a numerical value N for an <exact numeric type> T is a value V
representablein T such that N is not closer to zero than the numerical value of V and such that the absolute value of
thedifference between N and the numer- ical value of V is less than the absolute value of the difference between two
successivenumerical values representable in T.
 
 An approximation obtained by rounding of a numerical value N for an <exact numeric type> T is a value V representable
inT such that the absolute value of the difference between N and the nu- merical value of V is not greater than half
theabsolute value of the difference between two successive numerical values repre- sentable in T. If there are more
thanone such values V, then it is implementation-defined which one is taken.
 
 All numerical values between the smallest and the largest value, inclusive, representable in a given exact numeric
typehave an approximation obtained by rounding or truncation for that type; it is implementation-defined which other
numericalvalues have such approximations.
 


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

Предыдущее
От: jwieck@debis.com (Jan Wieck)
Дата:
Сообщение: Problems on NUMERIC
Следующее
От: "Thomas G. Lockhart"
Дата:
Сообщение: Re: [HACKERS] Problems on NUMERIC