Initial revision
[LeanCalc.git] / help / base
1 NAME
2     base - set default output base
3
4 SYNOPSIS
5     base([mode])
6
7 TYPES
8     mode        real
9
10     return      real
11
12 DESCRIPTION
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.
18
19     The following convention is used to declare modes:
20
21              base       equivalent
22                       config("mode")'s
23
24                2        "binary"        base 2 fractions
25                         "bin"
26
27                8        "octal"         base 8 fractions
28                         "oct"
29
30               10        "real"          base 10 floating point
31                         "float"
32                         "default"
33
34              -10        "integer"       base 10 integers
35                         "int"
36
37               16        "hexadecimal"   base 16 fractions
38                         "hex"
39
40              1/3        "fraction"      base 10 fractions
41                         "frac"
42
43             1e20        "scientific"    base 10 scientific notation
44                         "sci"
45                         "exp"
46
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
49     scientific notation.
50
51     These base() calls have the same meaning as config("mode", "fraction"):
52
53         base(1/3)       base(0.1415)    base(16/37)
54
55     These base() calls have the same meaning as config("mode", "scientific"):
56
57         base(1e20)      base(2^64)      base(2^8191-1)
58
59     However the base() function will only return one of the base values
60     listed in the table above.
61
62 EXAMPLE
63     > base()
64             10
65
66     > base(8)
67             012
68
69     > print 10
70     012
71
72 LIMITS
73     none
74
75 LINK LIBRARY
76     int math_setmode(int newmode)
77
78     NOTE: newmode must be one of MODE_DEFAULT, MODE_FRAC, MODE_INT,
79           MODE_REAL, MODE_EXP, MODE_HEX, MODE_OCTAL, MODE_BINARY
80
81 SEE ALSO
82     base2, config, str
83