bc: About Expressions and Special Variables
1
1 3.1 About Expressions and Special Variables
1 ===========================================
1
1 The numbers are manipulated by expressions and statements. Since the
1 language was designed to be interactive, statements and expressions are
1 executed as soon as possible. There is no main program. Instead, code
1 is executed as it is encountered. (Functions, discussed in detail
1 later, are defined when encountered.)
1
1 A simple expression is just a constant. 'bc' converts constants into
1 internal decimal numbers using the current input base, specified by the
1 variable IBASE. (There is an exception in functions.) The legal values
1 of IBASE are 2 through 36. (Bases greater than 16 are an extension.)
1 Assigning a value outside this range to IBASE will result in a value of
1 2 or 36. Input numbers may contain the characters 0-9 and A-Z. (Note:
1 They must be capitals. Lower case letters are variable names.) Single
1 digit numbers always have the value of the digit regardless of the value
1 of IBASE. (i.e. A = 10.) For multi-digit numbers, 'bc' changes all
1 input digits greater or equal to IBASE to the value of IBASE-1. This
1 makes the number 'ZZZ' always be the largest 3 digit number of the input
1 base.
1
1 Full expressions are similar to many other high level languages.
1 Since there is only one kind of number, there are no rules for mixing
1 types. Instead, there are rules on the scale of expressions. Every
1 expression has a scale. This is derived from the scale of original
1 numbers, the operation performed and in many cases, the value of the
1 variable SCALE. Legal values of the variable SCALE are 0 to the maximum
1 number representable by a C integer.
1