summaryrefslogtreecommitdiff
path: root/source/text/scalc/01/func_trunc.xhp
blob: 22b58a2784e4ed5a43e6eef4b17a6e0098583022 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 -->

<meta>
  <topic id="trunc_function" indexer="include" status="PUBLISH">
    <title id="tit" xml-lang="en-US">TRUNC function</title>
    <filename>/text/scalc/01/func_trunc.xhp</filename>
  </topic>
</meta>

<body>
  <bookmark xml-lang="en-US" branch="index" id="bm_id3156384">
    <bookmark_value>TRUNC function</bookmark_value>
    <bookmark_value>decimal places;cutting off</bookmark_value>
    <bookmark_value>numbers;truncate</bookmark_value>
  </bookmark>
  <bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_KUERZEN" id="bm_id3157849" localize="false"/>
  <h1 id="hd_id601641846107898"><variable id="trunc_h1"><link href="text/scalc/01/func_trunc.xhp" name="trunc_link">TRUNC function</link></variable></h1>
  <section id="trunc_desc">
    <paragraph role="paragraph" id="par_id841641927277474">Truncates a number while keeping a specified number of decimal digits.</paragraph>
  </section>
  <paragraph role="paragraph" id="par_id701642530512560">This function is equivalent to the <link href="text/scalc/01/func_rounddown.xhp" name="ROUNDDOWN_link">ROUNDDOWN function</link>.</paragraph>
  <section id="trunc_tip">
    <tip id="par_id321641927458888">The rounding method used by this function is known as <emph>rounding towards zero</emph>. The resulting number will always be smaller than or equal to the original number.</tip>
  </section>
  <embed href="text/scalc/01/common_func.xhp#sectionsyntax"/>
  <paragraph role="paragraph" id="par_id341641927560587">
    <input>TRUNC(Number [; Count])</input>
  </paragraph>
  <section id="trunc_parameters">
    <paragraph role="paragraph" id="par_id11641927688319"><emph>Number:</emph> The number to be truncated.</paragraph>
    <paragraph role="paragraph" id="par_id861641927715672"><emph>Count:</emph> Optional parameter that defines the number of decimal places to be kept. The default value is 0 (zero).</paragraph>
    <paragraph role="paragraph" id="par_id911641928545976">Use negative values for <emph>Count</emph> to round the integer part of the original <emph>Number</emph>. For example, -1 will round down the first integer number before the decimal separator, -2 will round down the two integer numbers before the decimal separator, and so forth.</paragraph>
  </section>
  <embed href="text/scalc/01/common_func.xhp#sectionexample"/>
  <paragraph role="paragraph" id="par_id901641928192870"><input>=TRUNC(21.89)</input> returns 21. Note that this example uses the default value for <emph>Count</emph> which is 0.</paragraph>
  <paragraph role="paragraph" id="par_id901641928192110"><input>=TRUNC(103.37,1)</input> returns 103.3.</paragraph>
  <paragraph role="paragraph" id="par_id171641928456743"><input>=TRUNC(0.664,2)</input> returns 0.66.</paragraph>
  <paragraph role="paragraph" id="par_id641641928712287"><input>=TRUNC(214.2,-1)</input> returns 210. Note the negative value for <emph>Count</emph>, which causes the first integer value before the decimal separator to be rounded towards zero.</paragraph>

  <section id="relatedtopics">
    <embed href="text/scalc/01/func_rounddown.xhp#rounddown_h1"/>
    <embed href="text/scalc/01/04060106.xhp#math_functions_h1"/>
  </section>
</body>
</helpdocument>