2 trunc - truncate a value to a number of decimal places
14 Truncate x to j decimal places. If j is omitted, 0 places is assumed.
15 Specifying zero places makes the result identical to int().
17 Truncation of a non-integer prodcues values nearer to zero.
20 ; print trunc(pi()), trunc(pi(), 5)
23 ; print trunc(3.333), trunc(3.789), trunc(3.333, 2), trunc(3.789, 2)
26 ; print trunc(-3.333), trunc(-3.789), trunc(-3.333, 2), trunc(-3.789, 2)
33 NUMBER *qtrunc(NUMBER *x, *j)
36 bround, btrunc, int, round
38 ## Copyright (C) 1999 Landon Curt Noll
40 ## Calc is open software; you can redistribute it and/or modify it under
41 ## the terms of the version 2.1 of the GNU Lesser General Public License
42 ## as published by the Free Software Foundation.
44 ## Calc is distributed in the hope that it will be useful, but WITHOUT
45 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
46 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
47 ## Public License for more details.
49 ## A copy of version 2.1 of the GNU Lesser General Public License is
50 ## distributed with calc under the filename COPYING-LGPL. You should have
51 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
52 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
54 ## @(#) $Revision: 30.1 $
55 ## @(#) $Id: trunc,v 30.1 2007/03/16 11:10:42 chongo Exp $
56 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/trunc,v $
58 ## Under source code control: 1994/09/30 00:52:38
59 ## File existed as early as: 1994
61 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
62 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/