third root of -8...

Post here to share useful tips and tricks, to ask questions about using your DM42 or to report software-related problems
ratwolf
Posts: 52
Joined: Fri Feb 12, 2021 1:00 am

Re: third root of -8...

Post by ratwolf »

...
Last edited by ratwolf on Tue Apr 20, 2021 1:34 pm, edited 1 time in total.
ratwolf
Posts: 52
Joined: Fri Feb 12, 2021 1:00 am

Re: third root of -8...

Post by ratwolf »

...
Last edited by ratwolf on Tue Apr 20, 2021 1:34 pm, edited 1 time in total.
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: third root of -8...

Post by Thomas Okken »

This "unary minus," having higher precedence than subtraction, is something I seem to have found in every parser textbook I've ever looked at, but I can't figure out where it comes from. It doesn't seem to have originated from mathematics, or at least, all the math textbooks I have ever seen put parentheses around -1 in expressions like (-1)^n. And those are rather common!

It's not like I've taken a survey on the subject, but I wonder how common this high-precedence unary minus really is in practice. In C it seems to be irrelevant, because C doesn't have an exponentiation operator, and the HP-17B and 27S appear to give unary minus the same precedence as subtraction.
ratwolf
Posts: 52
Joined: Fri Feb 12, 2021 1:00 am

Re: third root of -8...

Post by ratwolf »

...
Last edited by ratwolf on Tue Apr 20, 2021 1:35 pm, edited 1 time in total.
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: third root of -8...

Post by Thomas Okken »

Yep, so that behaves like unary minus has the same precedence as subtraction, per the convention in written math. The calculator equivalents would be 8 +/- ENTER 3 1/X Y^X and 8 ENTER 3 1/X Y^X +/-, respectively.
User avatar
ijabbott
Posts: 253
Joined: Fri Dec 15, 2017 2:34 pm
Location: GB-MAN

Re: third root of -8...

Post by ijabbott »

Thomas Okken wrote:
Mon Mar 22, 2021 11:01 am
This "unary minus," having higher precedence than subtraction, is something I seem to have found in every parser textbook I've ever looked at, but I can't figure out where it comes from. It doesn't seem to have originated from mathematics, or at least, all the math textbooks I have ever seen put parentheses around -1 in expressions like (-1)^n. And those are rather common!

It's not like I've taken a survey on the subject, but I wonder how common this high-precedence unary minus really is in practice. In C it seems to be irrelevant, because C doesn't have an exponentiation operator, and the HP-17B and 27S appear to give unary minus the same precedence as subtraction.
OTOH, if C did have an exponentiation operator, it would probably have lower precedence than unary minus. All the unary prefix operators in C essentially have the same precedence, higher than any of the binary operators, so adding a binary operator with higher precedence would uglify the syntax somewhat.
Post Reply