Thread Closed 
(-) precedence
12-08-2022, 10:23 PM
Post: #21
RE: (-) precedence
Right.
Visit this user's website Find all posts by this user
12-09-2022, 12:15 AM
Post: #22
RE: (-) precedence
(12-08-2022 10:23 PM)Thomas Okken Wrote:  Right.

Now I know I’m on the right track. Thanks!
Find all posts by this user
12-09-2022, 02:52 PM
Post: #23
RE: (-) precedence
I don't think that anyone has mentioned that the Prime has *both* operators. A subtraction operator and the unary minus, each with different symbols. In this case, I think the unary minus should bind tighter to the number.
Find all posts by this user
12-09-2022, 04:02 PM
Post: #24
RE: (-) precedence
(12-08-2022 09:21 PM)Thomas Okken Wrote:  Unary minus should have the same precedence as binary minus, that's the way it works in standard mathematical notation. Another way of understanding it is that -x is shorthand for 0-x.

This is how modern Fortran does it, but many others had unary +/- above * / mod.

(-a)*b = -(a*b)
(-a)/b = -(a/b)

We don't notice any difference until we added MOD operator.
For example, this is from HP Prime emulator:

CAS> 2 * 3 MOD 4      → 2
CAS> 2 MOD 3 * 4      → 8

This showed MOD had same precedence as MUL. It just evaluate from left to right.

CAS> - 10 MOD 7      → 4
CAS> 0 - 10 MOD 7   → -3

This showed UNARY MINUS had higher precedence than MOD, thus also MUL and DIV
Find all posts by this user
12-10-2022, 01:51 AM
Post: #25
RE: (-) precedence
(12-09-2022 02:52 PM)KeithB Wrote:  I don't think that anyone has mentioned that the Prime has *both* operators. A subtraction operator and the unary minus, each with different symbols. In this case, I think the unary minus should bind tighter to the number.

I never noticed the Prime display of negative versus negation, but you are correct. Neat! The Prime negative indicator reminds me of the APL "high minus" in which a negative number uses the "¯" symbol to indicate a negative number, as in

¯2 as opposed to -2

That of course means ¯2 is negative two (not the negation of two or 0-2) and ¯2*2 (* is power of) equals 4 as expected, whereas -2*2 is ¯4 because APL expressions are evaluated right to left (no function precedence nonsense), and thus negation is applied last. The '-' symbol is subtraction with a LHS argument and negation without, so then 2--2 is 4 (obviously Wink )

APL is a mathematical notation developed by a Mathematician. Wish I had an APL calculator Smile

Remember kids, "In a democracy, you get the government you deserve."
Find all posts by this user
12-10-2022, 03:42 AM
Post: #26
RE: (-) precedence
(12-10-2022 01:51 AM)mfleming Wrote:  APL is a mathematical notation developed by a Mathematician. Wish I had an APL calculator Smile

Now that is a calculator keyboard I would really like to see!! Smile

--Bob Prosperi
Find all posts by this user
12-10-2022, 04:18 PM (This post was last modified: 12-10-2022 04:18 PM by Maximilian Hohmann.)
Post: #27
RE: (-) precedence
Hello!

(12-10-2022 03:42 AM)rprosperi Wrote:  Now that is a calculator keyboard I would really like to see!! Smile

If you have a device that runs Android you can compile an APL calculator app from here: https://github.com/dzaima/APL/tree/master/AndroidIDE
There are some pictures of the keyboard furher down the page. To be honest, for me a keyboard like that looks rather scary ;-) But at least one never needs to think about operator precence ever again.

Regards
Max
Find all posts by this user
12-10-2022, 04:38 PM
Post: #28
RE: (-) precedence
(12-10-2022 04:18 PM)Maximilian Hohmann Wrote:  But at least one never needs to think about operator precedence ever again.

Well, one doesn't need to think about operator precedence if one uses RPN... Smile

OTOH, it should be possible to make an APL interpreter for the Prime although it would require the use of custom characters since the Prime doesn't include the APL code page.
Find all posts by this user
12-10-2022, 05:57 PM
Post: #29
RE: (-) precedence
(12-10-2022 04:18 PM)Maximilian Hohmann Wrote:  But at least one never needs to think about operator presence ever again.
Regards
Max

One never has to worry about automatic precedence ever again but you still have to worry about precedence. Only now, it's all up to you!

Tom L
Cui bono?
Find all posts by this user
12-10-2022, 06:56 PM
Post: #30
RE: (-) precedence
(12-10-2022 04:18 PM)Maximilian Hohmann Wrote:  Hello!

(12-10-2022 03:42 AM)rprosperi Wrote:  Now that is a calculator keyboard I would really like to see!! Smile

If you have a device that runs Android you can compile an APL calculator app from here: https://github.com/dzaima/APL/tree/master/AndroidIDE
There are some pictures of the keyboard furher down the page. To be honest, for me a keyboard like that looks rather scary ;-) But at least one never needs to think about operator precence ever again.

Regards
Max

Thanks Max. Those keyboard images confirm my very worst fears of how truly hostile such an APL keyboard would appear. Note I said "...would really like to see...". I certainly would never want to use such a beast, I fear it may cause permanent loss of brain function as regards using RPN. Waaaay too risky...

--Bob Prosperi
Find all posts by this user
12-10-2022, 10:22 PM
Post: #31
RE: (-) precedence
I have mixed feelings about APL- it exemplifies the ideal of a small, flexible set of powerful tools, which I admire. There may well be sound ideas behind the symbols but they are non-intuitive and hermetic. Overall a mixture of the good, the not-so-good and the just plain crazy!

There is a newer dialect called J which uses standard ASCII characters but it manages to be even less readable.
Find all posts by this user
12-10-2022, 11:23 PM
Post: #32
RE: (-) precedence
(12-10-2022 04:18 PM)Maximilian Hohmann Wrote:  Hello!


If you have a device that runs Android you can compile an APL calculator app from here: https://github.com/dzaima/APL/tree/master/AndroidIDE
There are some pictures of the keyboard furher down the page. To be honest, for me a keyboard like that looks rather scary ;-) But at least one never needs to think about operator precence ever again.

Regards
Max
I tried that a few years ago but found it was difficult to view on the small screen of a phone. Looks like they've added connectivity to a Dyalog server via Ride, so I'll have to try this again on a tablet. Thanks Max.

(12-10-2022 06:56 PM)rprosperi Wrote:  Thanks Max. Those keyboard images confirm my very worst fears of how truly hostile such an APL keyboard would appear. Note I said "...would really like to see...". I certainly would never want to use such a beast, I fear it may cause permanent loss of brain function as regards using RPN. Waaaay too risky...

Actually, an APL calculator would look an awful lot like a DM42 with a slightly different faceplate. If you're doing some quick calculations you wouldn't want to type 1○○0.25 to get the sine of pi/4 or ⍟27 for natural log of 27. Just leave the main keys as they are. All those chicken-scratch symbols would be available from a few soft menus above the unlabeled top keys, much like the DM42 or WP43. Have an option to show your equation as-is or display the APL equivalent to what you typed in. Learn APL as you go along.

The display would look like a series of expressions and results displayed like the Prime or HP48/50. Now how might one combine APL with an RPN stack Smile

Remember kids, "In a democracy, you get the government you deserve."
Find all posts by this user
12-11-2022, 08:29 AM
Post: #33
RE: (-) precedence
On the slightly drifted topic of APL in the wild, the luggable MCM/70 from 1974 (announced in '73) is well worth knowing about:
https://museum.eecs.yorku.ca/exhibits/sh...exhibit_p1
Find all posts by this user
12-11-2022, 10:38 AM
Post: #34
RE: (-) precedence
Hello!

(12-11-2022 08:29 AM)EdS2 Wrote:  On the slightly drifted topic of APL in the wild, the luggable MCM/70 from 1974 (announced in '73) is well worth knowing about

Very interesting calculator, thanks for posting the link. The keyboard seems to be of the the "mild APL" variant though. Just a few mathematical symbols on shifted keys most of which even I recognise :-)

Regards
Max
Find all posts by this user
12-11-2022, 01:27 PM
Post: #35
RE: (-) precedence
(12-11-2022 08:29 AM)EdS2 Wrote:  On the slightly drifted topic of APL in the wild, the luggable MCM/70 from 1974 (announced in '73) is well worth knowing about:
https://museum.eecs.yorku.ca/exhibits/sh...exhibit_p1

Pretty amazing given the limited capability of the 8008. I can remember the early portables (uh, luggables) with built-in cassette drives.

Here's something from '75 I occasionally search The Bay for
https://en.m.wikipedia.org/wiki/IBM_5100

APL the language (as opposed to the notation) would never have come about were it not for the interchangeable type balls of the IBM Selectric typewriter.

Remember kids, "In a democracy, you get the government you deserve."
Find all posts by this user
12-12-2022, 04:37 PM
Post: #36
RE: (-) precedence
(12-10-2022 01:51 AM)mfleming Wrote:  
(12-09-2022 02:52 PM)KeithB Wrote:  I don't think that anyone has mentioned that the Prime has *both* operators. A subtraction operator and the unary minus, each with different symbols. In this case, I think the unary minus should bind tighter to the number.

I never noticed the Prime display of negative versus negation, but you are correct. Neat! The Prime negative indicator reminds me of the APL "high minus" in which a negative number uses the "¯" symbol to indicate a negative number, as in

¯2 as opposed to -2

That of course means ¯2 is negative two (not the negation of two or 0-2) and ¯2*2 (* is power of) equals 4 as expected, whereas -2*2 is ¯4 because APL expressions are evaluated right to left (no function precedence nonsense), and thus negation is applied last. The '-' symbol is subtraction with a LHS argument and negation without, so then 2--2 is 4 (obviously Wink )

APL is a mathematical notation developed by a Mathematician. Wish I had an APL calculator Smile

This is probably not the APL calculator you could dream of, but it may be of interest to you and/or other readers.

https://home.gwu.edu/~nbrenner/
↳ direct link: https://home.gwu.edu/~nbrenner/49GNotes.txt

BTW: on RPL calculators (28 → 50), the algebraic expression '-2^2' gives -4 as a résult.

Bruno
Sanyo CZ-0124 ⋅ TI-57 ⋅ HP-15C ⋅ Canon X-07 + XP-140 Monitor Card ⋅ HP-41CX ⋅ HP-28S ⋅ HP-50G ⋅ HP-50G
Find all posts by this user
12-12-2022, 10:13 PM
Post: #37
RE: (-) precedence
Nice find! I'll have to spend some time with this and my 50...

Remember kids, "In a democracy, you get the government you deserve."
Find all posts by this user
12-12-2022, 11:56 PM
Post: #38
RE: (-) precedence
(12-12-2022 04:37 PM)FLISZT Wrote:  (…)
https://home.gwu.edu/~nbrenner/
↳ direct link: https://home.gwu.edu/~nbrenner/49GNotes.txt
(…)

- A small addition to my post -

Take a look at: https://www.hpcalc.org/details/7412

Bruno
Sanyo CZ-0124 ⋅ TI-57 ⋅ HP-15C ⋅ Canon X-07 + XP-140 Monitor Card ⋅ HP-41CX ⋅ HP-28S ⋅ HP-50G ⋅ HP-50G
Find all posts by this user
12-13-2022, 03:59 PM
Post: #39
RE: (-) precedence
The problem here is that we're using the same "-" character for three different, albeit related, concepts:
  • Subtraction: a - b
  • Unary negation: -x
  • Negative numbers: -2.3
It's easy enough to say that unary negation has lower precedence than powers, and thus -x2 is -(x2), but we have an understandable aversion to saying that to square the number -2.3, you must put parentheses around it (-2.3)2). It's the same aversion to saying that 2.32 should be 2+(.32) because the powers should have higher precedence than the radix mark. The radix mark is part of the number, and since numbers atomic, their expression naturally should not require parentheses.

If only we used a different symbol to signify that a number is negative, all this confusion would disappear. Unfortunately, we're stuck with the notation that we have.
Find all posts by this user
12-13-2022, 06:12 PM
Post: #40
RE: (-) precedence
(12-13-2022 03:59 PM)David Hayden Wrote:  we have an understandable aversion to saying that to square the number -2.3, you must put parentheses around it (-2.3)2)

That "we" does not include just about every single math textbook I have ever laid eyes on. See my example in the second post of this thread for a very typical example...
Visit this user's website Find all posts by this user
Thread Closed 




User(s) browsing this thread: 9 Guest(s)