2 base - set default output base
13 The base function allows one to specify how numbers should be
14 printed. The base function provides a numeric shorthand to the
15 config("mode") interface. With no args, base() will return the
16 current mode. With 1 arg, base(val) will set the mode according to
17 the arg and return the previous mode.
19 The following convention is used to declare modes:
24 2 "binary" base 2 fractions
27 8 "octal" base 8 fractions
30 10 "real" base 10 floating point
34 -10 "integer" base 10 integers
37 16 "hexadecimal" base 16 fractions
40 1/3 "fraction" base 10 fractions
43 1e20 "scientific" base 10 scientific notation
47 For convenience, any non-integer value is assumed to mean base 10
48 fractions and any integer >= 2^64 is assumed to mean base 10
51 These base() calls have the same meaning as config("mode", "fraction"):
53 base(1/3) base(0.1415) base(16/37)
55 These base() calls have the same meaning as config("mode", "scientific"):
57 base(1e20) base(2^64) base(2^8191-1)
59 However the base() function will only return one of the base values
60 listed in the table above.
76 int math_setmode(int newmode)
78 NOTE: newmode must be one of MODE_DEFAULT, MODE_FRAC, MODE_INT,
79 MODE_REAL, MODE_EXP, MODE_HEX, MODE_OCTAL, MODE_BINARY
84 ## Copyright (C) 1999 Landon Curt Noll
86 ## Calc is open software; you can redistribute it and/or modify it under
87 ## the terms of the version 2.1 of the GNU Lesser General Public License
88 ## as published by the Free Software Foundation.
90 ## Calc is distributed in the hope that it will be useful, but WITHOUT
91 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
92 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
93 ## Public License for more details.
95 ## A copy of version 2.1 of the GNU Lesser General Public License is
96 ## distributed with calc under the filename COPYING-LGPL. You should have
97 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
98 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
100 ## @(#) $Revision: 30.1 $
101 ## @(#) $Id: base,v 30.1 2007/03/16 11:10:42 chongo Exp $
102 ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/base,v $
104 ## Under source code control: 1994/09/30 00:09:39
105 ## File existed as early as: 1994
107 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
108 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/