Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:22 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Should I fly to the moon using the cmm2 as flight computer?

     Page 2 of 3    
Author Message
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6792
Posted: 09:25am 01 Jan 2024
Copy link to clipboard 
Print this post

I hope they wouldn't be using the Apollo Guidance system for anything important now. It wasn't all that much more powerful than, say, a 16-bit version of a TRS-80 with core store ROM for program storage. Things have moved on a bit. They could probably replace it with the much more capable Pico. :)

The technology wasn't lost so much as abandoned.
Edited 2024-01-01 19:27 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
andreas

Senior Member

Joined: 07/12/2020
Location: Germany
Posts: 207
Posted: 10:42am 01 Jan 2024
Copy link to clipboard 
Print this post

  Mixtel90 said  I hope they wouldn't be using the Apollo Guidance system for anything important now. It wasn't all that much more powerful than, say, a 16-bit version of a TRS-80 with core store ROM for program storage. Things have moved on a bit. They could probably replace it with the much more capable Pico. :)

The technology wasn't lost so much as abandoned.


The real "Guidance system for Apollo" was Katherine Johnson , who died 2020. She calculated everything by hand.

-andreas
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6792
Posted: 10:55am 01 Jan 2024
Copy link to clipboard 
Print this post

Yep - the electronic box was basically a pre-programmed calculator. It had several programs in its ROM.


Have a play with a guidance computer. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1241
Posted: 01:39pm 01 Jan 2024
Copy link to clipboard 
Print this post

  swoodgate said  ...

Check out Arbitrary-precision arithmetic libraries for solutions to this problem.

Steve


BCD Library

Wikipedia(.de):
  Quote  “What art thou (O Man) and from whence hadst thou thy beginning? What matter art thou made of, that thou promisest to thy selfe length of daies: or to thy posterity continuance. I have read the truest computer of Times, and the best Arithmetician that ever breathed, an he reduceth thy dayes into a short number: The daies of Man are threescore and ten.”

– Richard Brathwaite, „The Yong Mans Gleanings“, 1613



Remember: This is a Computer

EDIT: Opps, Andreas was faster ...

Regards
Michael
Edited 2024-01-01 23:41 by twofingers
causality ≠ correlation ≠ coincidence
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 03:13pm 01 Jan 2024
Copy link to clipboard 
Print this post

  matherp said  Because it has added 1.0 each time and 3.0 cannot be exactly represented (amongst others)

1. I don't see how that explains the particularly odd result i.e. the one with explicit 19

2. using floating point for counting integers (below a quite big threshold) normally is exact (*) and the results for the loop suggest that's the case

(*) and always is for IEEE I believe

3. using Geoff's old MMBasic for Linux gives the same results for both loop and explicit expression

4. MMB4L doesn't give the same results

Did something change (to explain the oddity) between the rather old Linux version (MMBasic Version 4.4.07e) and the newer ones?

John
Edited 2024-01-02 01:15 by JohnS
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 08:18pm 01 Jan 2024
Copy link to clipboard 
Print this post

  JohnS said  

3. using Geoff's old MMBasic for Linux gives the same results for both loop and explicit expression

4. MMB4L doesn't give the same results

Did something change (to explain the oddity) between the rather old Linux version (MMBasic Version 4.4.07e) and the newer ones?

John

Early versions of MMBasic were 32 bit floating point only - no integers.

Without knowing if your example gives results consistent with floating point or integers, I assume that it is floating point.

That did make life easier in some respects.

I think integers appeared in V4.6 or thereabouts.

Jim
VK7JH
MMedit   MMBasic Help
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 482
Posted: 08:59pm 01 Jan 2024
Copy link to clipboard 
Print this post

  Quote  Early versions of MMBasic were 32 bit floating point only - no integers.


My impression was, 32bit floating point would only handle numbers as definite integers up to 16 million or so, and the Maximite basic had another bit issue which reduced it further to a max integer magnitude of a little over 8 million.  I guess odd-value integers over that magnitude were treated as even numbers (?).
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 09:05pm 01 Jan 2024
Copy link to clipboard 
Print this post

From the V4.5 manual
  Quote  Numbers are stored and manipulated as single precision floating point numbers. The maximum number that
can be represented is 3.40282347e+38 and the minimum is 1.17549435e-38
The range of integers (whole numbers) that can be manipulated without loss of accuracy is ±8388608 (23 bits).

VK7JH
MMedit   MMBasic Help
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 09:58pm 01 Jan 2024
Copy link to clipboard 
Print this post

All of that may well be the case but as far as I can see fails to explain what I have raised.

I certainly can't see the relevance (or accuracy) of Peter's message about 3.0.

As an aside, cos(pi/2) isn't zero using floating point because pi isn't quite the exact value of the mathematical concept of pi, thus pi/2 is a way off the exact value in maths and cos(pi/2) also not quite the mathematical value.

Let's call it epsilon (a small value). Then epsilon gets multiplied by 10 to a power, such as 19. It should be the same whether 19 is explicit or comes from a loop counter (unless the loop counter can't store 19 exactly but it should manage that!).

Looks & smells like a bug.

It's a bug that probably doesn't matter when calculating based on cos(pi/2) but if it's a bug it'll bite elsewhere most probably.

John
Edited 2024-01-02 08:12 by JohnS
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 10:26pm 01 Jan 2024
Copy link to clipboard 
Print this post

print 10^19
print 10^19.0

first line is treated as INTEGER and overflows giving odd result.
second line is treated as a float.
(Tested on MMB4W and other platforms may be different)

Sometimes Integers are best, sometimes floats are best.
The only "bug" is, MMBasic has little overflow protection and it is up to the programmer to do the tests.

Jim
VK7JH
MMedit   MMBasic Help
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 11:01pm 01 Jan 2024
Copy link to clipboard 
Print this post

> print 10^19 :print 10^19.0
-8446744073709551616
1e+19

PicoMiteVGA MMBasic Version 5.08.08b2
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1109
Posted: 01:10am 02 Jan 2024
Copy link to clipboard 
Print this post

  Quote  > print 10^19 :print 10^19.0
-8446744073709551616
1e+19

Open Windows Calculator and set it Programmer mode.
Ensure decimal mode and type 1 followed by 18 zeros. (More than 18 zeros won't fit.)
Now multiply by 10.
The same result, -8,446,744,073,709,551,616 appears.
Visit Vegipete's *Mite Library for cool programs.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 08:05am 02 Jan 2024
Copy link to clipboard 
Print this post

  TassyJim said  
print 10^19
print 10^19.0

first line is treated as INTEGER and overflows giving odd result.
second line is treated as a float.
(Tested on MMB4W and other platforms may be different)

Yes. That's what has changed.

MMBasic used to behave like Microsoft's Basic (and many others) but no longer does.

It's now more like C...

edit: probably a good idea to change the manuals to remove or qualify the statement "MMBasic is a Microsoft BASIC compatible implementation ..."

John
Edited 2024-01-02 18:25 by JohnS
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6792
Posted: 09:07am 02 Jan 2024
Copy link to clipboard 
Print this post

"MMBasic is a Microsoft BASIC compatible implementation ..."
Was never 100% true as Microsoft BASIC would never run on a PIC chip. It's close enough for most purposes though. :)

When you are pushing numbers into the highest bit things will always get messed up. Programmers shouldn't do that as the poor computer doesn't know what you intended (unless you are able to define, say, an unsigned integer to throw an overflow message).
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 10:30am 02 Jan 2024
Copy link to clipboard 
Print this post

  Mixtel90 said  "MMBasic is a Microsoft BASIC compatible implementation ..."
Was never 100% true as Microsoft BASIC would never run on a PIC chip. It's close enough for most purposes though. :)

When you are pushing numbers into the highest bit things will always get messed up. Programmers shouldn't do that as the poor computer doesn't know what you intended (unless you are able to define, say, an unsigned integer to throw an overflow message).

Obviously it wasn't 100% true but at least the arithmetic behaved essentially the same - and no longer does so.

I'm not sure the best way to warn users but somewhere it maybe needs to be emphasised that a seemingly innocent expression now has this behaviour and you won't be warned that overflow has occurred.

This is explicit in C by design (and most C programs barely use floating point if at all). It isn't how Microsoft BASIC behaves or would be expected to behave AFAIK. Probably also not allowed by ANSI, ISO et al but I don't have a copy of such standards.  (Will go look if I can.)

John
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6792
Posted: 10:43am 02 Jan 2024
Copy link to clipboard 
Print this post

It's hardly surprising though. MMBasic is written in C AFAIK and will probably be using C libraries for the maths. The old BASIC interpreters were written in assembler.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 03:02pm 02 Jan 2024
Copy link to clipboard 
Print this post

  Mixtel90 said  It's hardly surprising though. MMBasic is written in C AFAIK and will probably be using C libraries for the maths. The old BASIC interpreters were written in assembler.

No, it's not that. It was C all along.

It used to work like Microsoft & other BASICs (and was C then as now).

The expression evaluator must have changed in some way to favour integer rather than floating point.  (Maybe when 64-bit integers were added?)

John
 
EDNEDN
Senior Member

Joined: 18/02/2023
Location: United States
Posts: 118
Posted: 03:04pm 02 Jan 2024
Copy link to clipboard 
Print this post

The biggest incompatibility with Microsoft BASIC for me is the structure of the IF / THEN statements when going to a different program location.

Microsoft BASIC would allow:

IF <some condition> THEN 1234
IF <some condition> THEN GOTO 1234
IF <some condition> GOTO 1234

And the first two forms were allowed on the ELSE part of the IF.

This would not be at all difficult to get in compliance with Microsoft BASIC if it bothered enough people.   But surprisingly, I haven't heard anybody mention it.
Edited 2024-01-03 01:06 by EDNEDN
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6792
Posted: 03:12pm 02 Jan 2024
Copy link to clipboard 
Print this post

GOTO isn't guaranteed to be supported in future versions of MMBasic.
MMBasic doesn't use "true" line numbers either - IIRC you can't jump to them unless you make them labels. You can use them but they are merely ignored.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9118
Posted: 03:55pm 02 Jan 2024
Copy link to clipboard 
Print this post

  Quote  MMBasic doesn't use "true" line numbers either - IIRC you can't jump to them unless you make them labels.


MMbasic fully supports goto and gosub to line numbers including the syntax variants posted above - just tested
Edited 2024-01-03 02:45 by matherp
 
     Page 2 of 3    
Print this page
© JAQ Software 2024