zx81 math question

Discussions about Sinclair ZX80 and ZX81 Hardware
Post Reply
Crayon21
Posts: 348
Joined: Sun Nov 04, 2018 2:33 am

zx81 math question

Post by Crayon21 »

in chapter 4 of the zx81 manual, the answer to the problem is 8. i get that. what boggles my mind is the logic behind the answer. It's as if the minds behind the zx81 thought that normal math routines weren't fashionable and decided to screw with our (american) heads. It makes no sense to me whatsoever as, being from the US, i was taught to follow math in a specific order (namely the PEMDAS system). Can someone explain this insanity or am i not the only crazy one? Are UK math classes different from ours? What is the meaning of this lunacy?

http://zxnext.narod.ru/manuals/ZX81_Manual.pdf
In Heck, there are two options for perpetual torment:

Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
:twisted:
User avatar
1024MAK
Posts: 5103
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: zx81 math question

Post by 1024MAK »

If you mean this:
PRINT 20-2*3**2+4/2*3

The only thing different is that the ZX81 uses different symbols, the most unusual being that it uses ‘**’ to mean ‘raise to the power’ (or exponent) rather than the symbol ‘^’.

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
David G
Posts: 387
Joined: Thu Jul 17, 2014 7:58 am
Location: 21 North, 156 West

Re: zx81 math question

Post by David G »

PRINT 20-2*3**2+4/2*3

This is a good brain-twister

Using my 1970s learnt order-of-operators, it all works out fine

but

this new PEMDAS idea messed with my head. At first I thought it meant "perform the Multiplications first, then the Divisions", but that results in the wrong answer. After many efforts, I tried "Muliplication and Division", which works well

Code: Select all

PRINT 20-2*3**2+4/2*3

PEMDAS
1. Parenthesis: none
2. Exponents:
   PRINT 20-2*3**2+4/2*3
              3**2
              9
   PRINT 20-2*9   +4/2*3
3. Multiplication
   PRINT 20-2*9   +4/2*3
            2*9   
   PRINT 20-18    +4/2*3
                     2*3
   PRINT 20-18    +4/6
   ***WRONG***
going back to step 2

Code: Select all

2. result
   PRINT 20-2*9   +4/2*3
3. Multiplication and Division
   PRINT 20-2*9   +4/2*3
            2*9      
   PRINT 20-18    +4/2*3
                   4/2
   PRINT 20-18    +2  *3
                   2  *3
   PRINT 20-18    +6
4. Addition and Subtraction
   PRINT 20-18    +6
         20-18
   PRINT 2        +6
         8
All these new-fangled math ideas! When I was schooled we didn't need to remember words like PEMDAS, we just looked up operator precedence in the manual (btw where is my manual, it was here a few days ago ...)
Crayon21
Posts: 348
Joined: Sun Nov 04, 2018 2:33 am

Re: zx81 math question

Post by Crayon21 »

yup, it's a different world from the 70's
In Heck, there are two options for perpetual torment:

Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
:twisted:
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: zx81 math question

Post by Moggy »

Crayon21 wrote: Fri Apr 02, 2021 12:26 am yup, it's a different world from the 70's
Tell me about i!

I was schooled in imperial measurement and pre decimal currency(farthings,halfpennies and guineas) and seen a hell of a lot of changes over time re mathematics, a lot of it for the better.
Post Reply