Usage: [i]rpn []... # infinite loop [i]rpn []... { -n }... [i]rpn -h # for this message. where: is one or more args each containing zero or more words; quoting of arguments is often a good idea! is no. of times to execute , or -1 for infinite loop. is : -h -- for this help message, and exit(0) -nobuf -- turn off buffering of stdout. Function: Uses the commands in to read data on to a stack, perform operations on it, and pop data off stack and write out. End-of-file on input silently stops program. Logic flow accomdated using if, while, loop, end, break and breakif. Note: irpn uses 32bit integer stack and rpn uses 64bit float stack. Examples: irpn read 10 min 20 max writehex In an infinite loop, reads a C-type integer numeral, windows between 10 and 20 and writes result out in hex. rpn 'readr32 2.5 * writer32' In an infinite loop, reads a 32bit float onto 64bit float stack, multiplies by 2.5, and writes out 32bit float result. Commands are: ((*) = rpn only; (+) = irpn only). read same as readnum (below). Reads C numeral. write same as writenum (below). Writes decimal numeral. read (for example, readi32 or readi32B). write (for example, writei32 or writei32L). read (write) a different type, converting to (from) the type used for the stack; where is one of (B=big-endian, L=little-endina): i16[B|L] 16bit signed integer ("binary"). u16[B|L] 16bit unsigned integer ("binary"). i32[B|L] 32bit signed integer ("binary"). u32[B|L] 32bit unsigned integer; treated as i32 if long long not available ("binary"). NOTE: if neither B or L suffix given, native byte order used. r32 32bit real number; rounded on read by irpn. r64 64bit real number; rounded on read by irpn. NOTE: r32, r64 format is cpu native format only num ascii numeral; on read, irpn accepts C language decimal, octal and hex notations; rpn accepts only floating point constants (decimal point optional); both irpn and rpn write in decimal (floating point as needed for rpn). hex ascii hex integer. (0x not expected or recognized). Truncates to integer for rpn write. dec ascii decimal integer even if begins with zero. irpn not read floating point numerals! rpn reads/writes floating point numerals. oct ascii octal integer. Truncates to integer for rpn write. dup pushes a copy of the top stack element. Same as dup:-1 . dup: pushes a copy of the stack element indentified by the index, where index is 0 for the bottom (beginning) of the stack, 1 for the next... and is -1 for the top (item that can be popped) of the stack, -2 for the next down... Index should be a C language integer constant. pop throws away the top stack element. [-][0x]{digit(s)} push the constant value indicated on stack. digits may be preceded with 0x for hex in which case a-f and A-F are allowed. The negation may be applied even to octal or hex numerals. If first digit is 0, octal assumed, unless 0x precedes digits, in which case hexadecimal. [-][digits][.][digits][{e|E}[-|+]digit[digit]] (at least one digit required). (* rpn only) (if evaluation as integer numeral fails) push the constant real value on the stack. + push(pop()+pop()) - temp=pop();push(pop()-temp) Thus '5 3 -' results in the value 2 on the stack. * push(pop()*pop()) / temp=pop();push(pop()/temp) Thus '7 3 /' results in the value 2 on the irpn stack. ++ increment value on top of stack -- decrement value on top of stack % (or mod) (+) temp=pop(); push(pop()%temp) MODULUS << (+) temp=pop(); push(pop()<> (+) temp=pop(); push(pop()>>temp) & (+) temp=pop(); push(pop()&temp) BITWISE AND | (+) temp=pop(); push(pop()|temp) BITWISE OR && (+) logical and || (+) logical or ==,<=,<,>=,> (+) (in)equality operators ? (+) temp1=pop();temp2=pop();pop()?temp1:temp2 abs push(abs(pop()) max push(max(pop(),pop()) min push(min(pop(),pop()) pi (*) put the constant pi (3.14159...) on stack. e (*) put the natural log base (2.718..) on stack sin (*) push(sin(pop())) arg in radians! cos (*) push(cos(pop())) arg in radians! tan (*) push(tan(pop())) arg in radians! atan (*) push(atan(pop())) result in radians! asin (*) push(asin(pop())) result in radians! acos (*) push(acos(pop())) result in radians! atan2 (*) temp=pop();push(atan2(pop(),temp)) sqrt (*) push(sqrt(pop())) exp (*) push(exp(pop())) e^x ln (*) push(ln(pop())) log_e(x) ^ or pow (*) push(pow(pop())) x^y floor (*) push(floor(pop())) round negatively ceil (*) push(ceil(pop())) round positively round (*) push(round(pop())) round to nearest integer loop (or {) ... end (or }) begin infinite loop break[:nlevels] break n loop levels (default 1) (stack depth reduced to non-break case of end of loop) breakif[:nlevels] break n loop levels (default 1) if popped value nonzero (stack depth reduced to non-break case of end of loop) if ... end jump to end if popped value is zero end (or }) jump back to loop ; or target of if stop stop program