DaveBirdsall commented on a change in pull request #1837: [TRAFODION-3306] Add 
the TRUNC Function in the Trafodion SQL Reference Manual
URL: https://github.com/apache/trafodion/pull/1837#discussion_r278779643
 
 

 ##########
 File path: 
docs/sql_reference/src/asciidoc/_chapters/sql_functions_and_expressions.adoc
 ##########
 @@ -12460,6 +12460,122 @@ CHAR(20). This expression uses the TRIM function to 
return the value
 TRIM(first_name) || ' ' || TRIM (last_name)
 ```
 
+[[trunc_function]]
+== TRUNC Function
+
+The TRUNC (TRUNCATE) function truncates `_numeric-expression_` on an optional 
`_decimal-place_` decimal position(s), that is, it rounds down 
`_numeric-expression_` to the nearest (or equal) integer closer to zero 
*without rounding*.
 
 Review comment:
   The second argument makes this description awkward. If the second argument 
were zero, then we are rounding down to the nearest integer closer to zero. If 
the second argument is positive. we aren't necessarily rounding to an integer. 
TRUNC(1.23,1) gives 1.2, and 1.2 isn't an integer. And I'm not sure what 
happens when the second argument is negative. Maybe TRUNC(123,-1) gives 120?
   
   If this is true, one way to describe this is TRUNC is like ROUND, except it 
always rounds toward zero.
   
   Here is a possible wordsmith (please do a bit of experimentation to see if 
this is right);
   
   The TRUNC (TRUNCATE) function truncates '_numeric-expression_'. If the 
second argument is not supplied, or is supplied and is zero, this rounds the 
'_numeric-expression_' to the nearest integer closer to zero. If the second 
argument is supplied and is positive, say, n, it rounds the 
'_numeric_expression_' to the nearest multiple of 10^-n that is closer to zero. 
In these two cases, decimal places to the right of the decimal point are 
effectively deleted. If the second argument is supplied and is negative, say, 
-n, it rounds '_numeric_expression_' to the nearest multiple of 10^n. Any 
decimal places to the right of the decimal point are effectively deleted.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to