1
0
forked from bonsai/harakit
coreutils/docs/rpn.1

70 lines
2.2 KiB
Groff
Raw Normal View History

2024-02-01 18:36:38 +00:00
.\" Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
2024-02-03 03:12:12 +00:00
.\" Copyright (c) 2024 DTB <trinity@trinity.moe>
2024-02-01 18:36:38 +00:00
.\"
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.TH rpn 1
.SH NAME
2024-02-03 03:12:12 +00:00
rpn \(en reverse polish notation evaluation
2024-02-01 18:36:38 +00:00
.SH SYNOPSIS
2024-02-03 03:12:12 +00:00
rpn
.RB [numbers...]\ [operators...]
2024-02-01 18:36:38 +00:00
.SH DESCRIPTION
2024-02-03 06:24:45 +00:00
Rpn parses and and evaluates reverse polish notation expressions either from the
standard input or by parsing its arguments. See the STANDARD INPUT section.
2024-02-03 03:12:12 +00:00
2024-02-04 00:20:31 +00:00
Upon evaluation, rpn will print the resulting number on the stack to the
standard output. Any further specified numbers will be placed on the stack
following the last outputted number.
2024-02-03 03:12:12 +00:00
For information on for reverse polish notation syntax, see rpn(7).
2024-02-01 18:36:38 +00:00
.SH STANDARD INPUT
2024-02-03 03:12:12 +00:00
If rpn is passed arguments, it interprets them as an expression to be evaluated.
Otherwise, it reads whitespace-delimited numbers and operations from the
standard input.
2024-02-04 00:20:31 +00:00
.SH DIAGNOSTICS
If encountering a syntax error, rpn will exit with the appropriate error code
as defined by sysexits.h(3) and print an error message.
2024-02-03 03:12:12 +00:00
.SH CAVEATS
Due to precision constraints and the way floats are represented in accordance
with the IEEE Standard for Floating Point Arithmetic (IEEE 754), floating-point
arithmetic has rounding errors. This is somewhat curbed by using the
second-highest float that can be represented in line with this standard to round
numbers to before outputting.
2024-02-01 18:36:38 +00:00
.SH RATIONALE
2024-02-03 03:12:12 +00:00
An infix notation calculation utility, bc(1p), is included in the POSIX
standard, but it doesnt accept expressions as arguments; in scripts, any
predefined, non-interactive input must be piped into the program. A dc(1)
pre-dates the standardized bc(1p), the latter originally being a preprocessor
for the former, and was included in UNIX v2 onward. While it implements reverse
polish notation, it still suffers from being unable to accept an expression as
an argument.
2024-02-01 18:36:38 +00:00
.SH AUTHOR
Written by Emma Tebibyte <emma@tebibyte.media>.
.SH COPYRIGHT
Copyright (c) 2024 Emma Tebibyte. License AGPLv3+: GNU AGPL version 3 or later
<https://gnu.org/licenses/agpl.html>.
.SH SEE ALSO
2024-02-03 06:24:45 +00:00
bc(1p), dc(1), rpn(7), IEEE 754