MPC(1) MPC(1) NAME mpc - extended precision arithmetic code generator SYNOPSIS mpc [ file ... ] DESCRIPTION Mpc generates C functions from a simple language that oper- ates on extended precision integers using the mp(2) library. LANGUAGE The language consists of a series of function definitions of the form: name ( parameter list ) { statements } All variables and parameters are extended precision integers and are passed by reference. Statements are separated by semicolon and the following statemens are defined: name = expression if ( condition ) { statements } else if ( condition ) { statements } else { statements } while ( condition ) { statements } break name ( parameter list ) mod ( modulus ) { statements } There is no distinction between input and output parameters, but conventionally, the outputs are put at the end of the parameter list and the language allows one to write F ( X, Y, Z ) as Y, Z = F ( X ) Expressions are composed out of the following arithmetic operations: + addition. - subtraction. * multiplication. / division, or multiplicative inverse when enclosed in mod block. % division remainder. ^ exponentiation. >>constant right shift by a constant. Page 1 Plan 9 (printed 5/11/21) MPC(1) MPC(1) <<constant left shift by a constant. condition?a:b pick a when condition is true, otherwise b when false. Conditions can use the following operations: == equality. != inequality. > bigger than. < smaller than. !condition negation. SOURCE /sys/src/cmd/mpc.y SEE ALSO mp(2) Page 2 Plan 9 (printed 5/11/21)