bc: Special Expressions
1
1 3.6 Special Expressions
1 =======================
1
1 There are a few more special expressions that are provided in 'bc'.
1 These have to do with user-defined functions and standard functions.
1 They all appear as "NAME'('PARAMETERS')'". ⇒Functions, for
1 user-defined functions. The standard functions are:
1
1 'length ( EXPRESSION )'
1 The value of the length function is the number of significant
1 digits in the expression.
1
1 'read ( )'
1 The 'read' function (an extension) will read a number from the
1 standard input, regardless of where the function occurs. Beware,
1 this can cause problems with the mixing of data and program in the
1 standard input. The best use for this function is in a previously
1 written program that needs input from the user, but never allows
1 program code to be input from the user. The value of the 'read'
1 function is the number read from the standard input using the
1 current value of the variable IBASE for the conversion base.
1
1 'scale ( EXPRESSION )'
1 The value of the 'scale' function is the number of digits after the
1 decimal point in the expression.
1
1 'sqrt ( EXPRESSION )'
1 The value of the 'sqrt' function is the square root of the
1 expression. If the expression is negative, a run time error is
1 generated.
1