Difference between revisions of "Manuals/calci/TRUNC"

From ZCubes Wiki
Jump to navigation Jump to search
Line 15: Line 15:
  
 
*If digits is not specified, Calci considers it as 0.
 
*If digits is not specified, Calci considers it as 0.
*TRUNC and INT functions are somewhat similar. TRUNC removes the fractional part of the number, where as INT rounds the number down to nearest integer.  
+
*TRUNC() and INT() functions are somewhat similar. TRUNC() removes the fractional part of the number, where as INT() rounds the number down to nearest integer.  
*INT and TRUNC work differently with negative numbers.
+
*INT() and TRUNC() work differently with negative numbers.
  
INT(-45.1) ''returns -45'' whereas  
+
INT(-45.1) ''returns -45'' whereas
 +
 
TRUNC(-45.1) ''returns -46''
 
TRUNC(-45.1) ''returns -46''
 +
*TRUNC() can be combined with other functions as below -
 +
 +
TRUNC(SUM(3.4545,6.7878),2) ''returns 10.24'' as a result.
  
 
== Examples ==
 
== Examples ==
 +
<div id="6SpaceContent" class="zcontent" align="left">
 +
 +
{| id="TABLE3" class="SpreadSheet blue"
 +
|- class="even"
 +
| class="  " | '''Function'''
 +
| class="  " | '''Output'''
 +
 +
|- class="odd"
 +
| class="sshl_f" |TRUNC(1000.34,1)
 +
| class="sshl_f" |1000.3
 +
 +
|- class="even"
 +
| class="sshl_f" |TRUNC(23.4546,4)
 +
| class="sshl_f" |23.4546
 +
 +
|- class="odd"
 +
| class="sshl_f" |TRUNC(34.98989898)
 +
| class="sshl_f" |34
 +
 +
|- class="even"
 +
| class="sshl_f" |TRUNC(-3.25)
 +
| class="sshl_f" |-3
 +
 +
|- class="odd"
 +
| class="sshl_f" |TRUNC(-222,2)
 +
| class="sshl_f" |-222
 +
|}
 +
 +
== See Also ==
 +
 +
*[[Manuals/calci/INT | INT]]
 +
 +
*[[Manuals/calci/ROUND | ROUND]]
 +
 +
*[[Manuals/calci/ROUNDUP | ROUNDUP]]
 +
 +
*[[Manuals/calci/ROUNDDOWN | ROUNDDOWN]]
 +
 +
*[[Manuals/calci/CEILING | CEILING]]
 +
 +
*[[Manuals/calci/FLOOR | FLOOR]]
 +
 +
==References==
 +
*[http://en.wikipedia.org/wiki/Even_and_odd_functions Even function]

Revision as of 16:04, 24 November 2013

TRUNC(number, digits)

  • Where 'number' is the number to truncate and
  • 'digits' is a number specifying the number of decimal places to be displayed in the result.

TRUNC() truncates a number to specified number of digits.

Description

TRUNC(number, digits)

For Example,

TRUNC(56.6878,2) returns 56.68 as a result.

  • If digits is not specified, Calci considers it as 0.
  • TRUNC() and INT() functions are somewhat similar. TRUNC() removes the fractional part of the number, where as INT() rounds the number down to nearest integer.
  • INT() and TRUNC() work differently with negative numbers.

INT(-45.1) returns -45 whereas

TRUNC(-45.1) returns -46

  • TRUNC() can be combined with other functions as below -

TRUNC(SUM(3.4545,6.7878),2) returns 10.24 as a result.

Examples

Function Output
TRUNC(1000.34,1) 1000.3
TRUNC(23.4546,4) 23.4546
TRUNC(34.98989898) 34
TRUNC(-3.25) -3
TRUNC(-222,2) -222

See Also

References