Skip to content

Commit

Permalink
Change the 'Result of NUMERIC Type Operation' simply (CUBRID#416)
Browse files Browse the repository at this point in the history
http://jira.cubrid.org/browse/CUBRIDMAN-110
http://jira.cubrid.org/browse/CBRD-24815

Change the contents of 'N(P1, S1) / N(P2, S2)' as below.
- The content is the same, but change the description to a formula.
   | Operation             | Maximum Precision                       | Maximum Scale |
   |-----------------------|-----------------------------------------|---------------|
   | N(p1, s1) + N(p2, s2) | max(p1 - s1, p2 - s2) + max(s1, s2) + 1 | max(s1, s2)   |
   | N(p1, s1) - N(p2, s2) | max(p1 - s1, p2 - s2) + max(s1, s2)     | max(s1, s2)   |
   | N(p1, s1) * N(p2, s2) | p1 + p2 + 1                             | s1 + s2       |
   | N(p1, s1) / N(p2, s2) | Pt = (p1 - s1) + s2 + max(9, max(s1, s2))<br /> Pt = (Pt > 38) ? 38 : Pt | St = max(9, max(s1, s2))<br /> St = (Pt > 38) ? min(9, St - (Pt - 38)) : St |

   https://www.cubrid.org/manual/en/11.2/sql/function/arithmetic_op.html#numeric-data-type-op-and-conversion
  • Loading branch information
youngjinj committed Aug 4, 2023
1 parent ad74856 commit 9420057
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 12 additions & 12 deletions en/sql/function/arithmetic_op.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,18 @@ The following table shows the total number of digits (*p*) and the number of dig

**Result of NUMERIC Type Operation**

+-----------------------+--------------------------------------------------------------------------------------------------------------------------+-------------------+
| Operation | Maximum Precision | Maximum Scale |
+=======================+==========================================================================================================================+===================+
| N(p1, s1) + N(p2, s2) | max(p1-s1, p2-s2)+max(s1, s2) +1 | max(s1, s2) |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+-------------------+
| N(p1, s1) - N(p2, s2) | max(p1-s1, p2-s2)+max(s1, s2) | max(s1, s2) |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+-------------------+
| N(p1, s1) * N(p2, s2) | p1+p2+1 | s1+s2 |
+-----------------------+--------------------------------------------------------------------------------------------------------------------------+-------------------+
| N(p1, s1) / N(p2, s2) | Let Pt = p1+max(s1, s2) + s2 - s1 when s2 > 0 and Pt = p1 in other cases; St = s1 when s1 > s2 and s2 in other cases; | |
| | the number of decimal places is min(9-St, 38-Pt) + St when St < 9 and St in other cases. | |
+-----------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
+-----------------------+---------------------------------------------+------------------------------------------------+
| Operation | Maximum Precision | Maximum Scale |
+=======================+=============================================+================================================+
| N(p1, s1) + N(p2, s2) | max(p1 - s1, p2 - s2) + max(s1, s2) + 1 | max(s1, s2) |
+-----------------------+---------------------------------------------+------------------------------------------------+
| N(p1, s1) - N(p2, s2) | max(p1 - s1, p2 - s2) + max(s1, s2) | max(s1, s2) |
+-----------------------+---------------------------------------------+------------------------------------------------+
| N(p1, s1) * N(p2, s2) | p1 + p2 + 1 | s1 + s2 |
+-----------------------+---------------------------------------------+------------------------------------------------+
| N(p1, s1) / N(p2, s2) | | Pt = (p1 - s1) + s2 + max(9, max(s1, s2)) | | St = max(9, max(s1, s2)) |
| | | Pt = (Pt > 38) ? 38 : Pt | | St = (Pt > 38) ? min(9, St - (Pt - 38)) : St |
+-----------------------+---------------------------------------------+------------------------------------------------+

**Example**

Expand Down
24 changes: 12 additions & 12 deletions ko/sql/function/arithmetic_op.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,18 @@

**NUMERIC 타입의 연산 결과**

+-----------------------+---------------------------------------------------------------------------------------------+---------------------------+
| 연산 | 결과의 최대 자릿수 | 결과의 소수점 이하 자릿수 |
+=======================+=============================================================================================+===========================+
| N(p1, s1) + N(p2, s2) | max(p1-s1, p2-s2)+max(s1, s2) +1 | max(s1, s2) |
+-----------------------+---------------------------------------------------------------------------------------------+---------------------------+
| N(p1, s1) - N(p2, s2) | max(p1-s1, p2-s2)+max(s1, s2) | max(s1, s2) |
+-----------------------+---------------------------------------------------------------------------------------------+---------------------------+
| N(p1, s1) * N(p2, s2) | p1+p2+1 | s1+s2 |
+-----------------------+---------------------------------------------------------------------------------------------+---------------------------+
| N(p1, s1) / N(p2, s2) | s2 > 0 이면 Pt = p1+max(s1, s2) + s2 - s1, 그 외에는 Pt = p1라 하고, s1 > s2 이면 St = s1, |
| | 그 외에는 s2라 하면, 소수점 이하 자릿수는 St < 9 이면 min(9-St, 38-Pt) + St, 그 외에는 St |
+-----------------------+---------------------------------------------------------------------------------------------+---------------------------+
+-----------------------+---------------------------------------------+------------------------------------------------+
| 연산 | 결과의 최대 자릿수 | 결과의 소수점 이하 자릿수 |
+=======================+=============================================+================================================+
| N(p1, s1) + N(p2, s2) | max(p1 - s1, p2 - s2) + max(s1, s2) + 1 | max(s1, s2) |
+-----------------------+---------------------------------------------+------------------------------------------------+
| N(p1, s1) - N(p2, s2) | max(p1 - s1, p2 - s2) + max(s1, s2) | max(s1, s2) |
+-----------------------+---------------------------------------------+------------------------------------------------+
| N(p1, s1) * N(p2, s2) | p1 + p2 + 1 | s1 + s2 |
+-----------------------+---------------------------------------------+------------------------------------------------+
| N(p1, s1) / N(p2, s2) | | Pt = (p1 - s1) + s2 + max(9, max(s1, s2)) | | St = max(9, max(s1, s2)) |
| | | Pt = (Pt > 38) ? 38 : Pt | | St = (Pt > 38) ? min(9, St - (Pt - 38)) : St |
+-----------------------+---------------------------------------------+------------------------------------------------+

**예제**

Expand Down

0 comments on commit 9420057

Please sign in to comment.