3 ms·
I use dc every now and then but I wish it'd do decimal math by default. 9 35 5 12 *+/p Furthermore I think it's strange that the order of the operands of
by unkown-unknowns 9y ago
I use dc every now and then but I wish it'd do decimal math by default.
9 35 5 12 *+/p
Furthermore I think it's strange that the order of the operands of the division operator is divisor as top-most value on the stack and dividend as second top-most value and not the other way around.
For example, to me it'd feel more natural if
3 5 /p
was equivalent to
5 / 3
in infix notation, not
3 / 5
Because when I think of a fraction I think of it as "dividend over divisor".
Edit: Actually I Googled and it makes sense now. I've been focusing on what's on the stack but if we look at what is provided as input instead then it becomes "calculate dividend, calculate divisor, divide". Longer example which shows this:
Algebraic expression
(4 + 2 * 5) / (1 + 3 * 2)
RPN
4 2 5 * + 1 3 2 * + /
- boomlinde 9y agoSome distributions use a ".dcrc" or some such that will be executed on startup. Dump "3k" in there to set the precision. The order of the operands of non-commutative operators reflects popular RPN calculators and Forth. You can swap the topmost elements of the stack with "r", for example "3 5r/p"