hippy
Posts: 5594
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 11:04 am

Heater wrote:
Mon Apr 15, 2019 3:54 am
As far as I can tell the original Pi experiments were using some little ATMEL processor. Also as far as I can tell that predates MicroPython and there isn't a Python for such devices. So where was this Python to come from? Did Eben write his own Python for it? Was it actually a bigger ATMEL like the ARM based ones?
My reading between the lines would imagine it that Eben fancied the idea of reinventing the home computer, could see a benefit and reason for doing that, saw Atmel chips as the way to do it, so built a prototype around those.

Later, after joining Broadcom, he saw there were better, more powerful, very capable and reasonably priced, chips which could make for a better home computer, and shifted in that direction.

Having done that, I imagine he asked himself what it should do, how it should work ?

Booting to Basic was how home computers had done things, so a similar concept would not be unreasonable. But Basic was 'old hat', Python the new kid on the block, so why not boot to Python rather than boot to Basic ? A home computer for the modern age.

I think that's where the 'Pi for Python' comes in. That's what he imagined he would do, but then the notion of making it a cheap Linux computer arose; one which could run Python and anything else. His direction evolved again and that's what we ended up with.

I think it's an evolutionary tale rather than Eben having set off with the initial intent of creating a boot to Python computer using Atmel chips.

Heater
Posts: 12962
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 11:17 am

In another desperate attempt to avoid BASIC I spent an couple of hours trying to rise to the fibo(4784969) challenge in YAFL, this time Smalltalk.

Like Forth, Smalltalk syntax induces disorientation, nausea and headaches but after a couple of hours I came up with this:

Code: Select all

Integer extend [
    fibo [ | k fk fk1 | 
        (self < 2)
            ifTrue: [
                ^ self ].
        (self = 2)
            ifTrue: [
                ^ 1
            ].
        (self > 2)
            ifTrue: [
                k := (self + 1) // 2. 
                fk := k fibo.
                fk1 := (k - 1) fibo.
                (self odd)
                    ifTrue: [
                        ^ (fk raisedToInteger: 2) + (fk1 raisedToInteger: 2)
                    ]
                    ifFalse: [
                        ^ ((2 * fk1) + fk) * fk.
                    ]
            ]
    ]
]

8576 fibo printNl.    

8576 fibo printNl.
Which produces the correct result up to 8576 under GNU Smalltalk but produces long random numbers after that.

Code: Select all

$ gst fibo.gst
"Global garbage collection... done"
8482381118002198079364100053612866704390632782542247538837634248590642562985242013396072602915066560628421097484901036998441988116391540893969626215818497771155578604488478072504888862903379241897635690279639560845177722736699287257573334204971495746790211109060507119158614457715671368409667645906177479270912125898480649618125158364272968349787514949348270059405923429965126727549184307741476619056027751811142589550677649160536858263907917592546280925164278480873239633863691185424269150008526985110772503730666191701044524972666527595133985896370198613621319471513104773044566349326303798552791045016924723800238630216842037411776866472718131676087574874509314610784134645499164928338012726842966441247037829723715237611677209617849016163221628351875064221018691317219534434028993946039987237658776567837600861472350783839154588163456398808245395631990179367210442111796568339913257375018837446506268677092127368210829257441509639896765675580571740887500070459912170210818803994922441719797252319955216221361433291035455743036733226619694724840739216472839549514078019963670005482680984707765796815952100498970685401973499635081409210464386466962502998257063521370524204678187752202497473915970188203528268764821983382416780155850757306632031797958029142240652215713102968486947716004740353413411217472430486123954559419374711239244852433576642852551172955024660315089253066456772695295868984959453042639196095291874120092486346774978076332814518707712560844311990195671506038429727917793741640391310596565454155440552880383012677340635440159732920941368861519748371680389644004212265627942654018514299590440485282218586354146463319878877221490730205119480025830988114682266919972428994603843116357335905539031921934589288481581544404592415031967677722243698867319794090431843601225589957
Sadly GNU Smalltalk seems to not have any big integer type to drop in there. If anyone knows how to get this working up to 4784969 that would be great.

My apologies to Smalltalk old hands for my likely bad style and formatting. There does not seem to be anyway to format Smalltalk source nicely.
Last edited by Heater on Mon Apr 15, 2019 1:10 pm, edited 3 times in total.

jahboater
Posts: 4595
Joined: Wed Feb 04, 2015 6:38 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 11:23 am

Heater wrote:
Mon Apr 15, 2019 11:17 am

Sadly GNU Smalltalk seems to not have any big integer type to drop in there. If anyone knows how to get this working up to 4784969 that would be great.
It must be using a large integer type because fibo(8576) is way way past what can be held in 64-bits.
This little program:-

Code: Select all

#include <stdio.h>
#include <inttypes.h>

#define add(sum,n,m) !__builtin_add_overflow( n, m, &sum )

int
main( void )
{
  int term;
  uint64_t n, a = 0, b = 1;

  for( term = 1; add( n, a, b ); ++term )
  {
    a = b;
    b = n;
  }

  printf( "Term %d: %" PRIu64 "\n", term, b );
}
prints

Term 93: 12200160415121876738
Last edited by jahboater on Mon Apr 15, 2019 11:54 am, edited 1 time in total.

Heater
Posts: 12962
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 11:29 am

Yes but how large?

So far I have failed to find any documentation on the limits of GNU Smalltalk Integers.

Edit: I did find it: https://www.gnu.org/software/smalltalk/ ... rgeInteger

No help here though.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23071
Joined: Sat Jul 30, 2011 7:41 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 12:23 pm

Prolog.

Someone do it in Prolog.

That's a dare!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
Paeryn
Posts: 2605
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 1:53 pm

jamesh wrote:
Mon Apr 15, 2019 12:23 pm
Prolog.

Someone do it in Prolog.

That's a dare!
Ask and ye shall be given ;-) Not very elegant and it's the basic slow method rather than a fast one but it does handle negatives.

Code: Select all

[email protected]:~/Programming/prolog $ cat fibo.prolog
fibo(0, 0) :- !.
fibo(1, 1) :- !.
fibo(N, X) :-
    N > 1 ->
        N1 is N - 1,
        N2 is N - 2,
        fibo(N1, X1),
        fibo(N2, X2),
        X is X1 + X2
    ;
        N1 is N + 1,
        N2 is N + 2,
        fibo(N1, X1),
        fibo(N2, X2),
        X is X2 - X1.
Running,

Code: Select all

[email protected]:~/Programming/prolog $ prolog -l fibo.prolog
Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 7.2.3)
Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- fibo(5, X), fibo(10, Y).
X = 5,
Y = 55.

?- fibo(-5, X), fibo(-10, Y).
X = 5,
Y = -55.

?-
% halt
She who travels light — forgot something.

Heater
Posts: 12962
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 2:00 pm

Looks good. How about extending it to the faster algorithm. As seen in Smalltalk above?

User avatar
Paeryn
Posts: 2605
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 2:38 pm

Was just working on that. I also have found what I was doing wrong when trying to deal with negative indices (which lead me to write it as a separate formula rather than the normal "calculate using the positive index and negate the result if it's an even index"). It's been a long time since I used Prolog (~25 years) so was just a little bit rusty.

Code: Select all

fastfibo(0, 0) :- !.
fastfibo(1, 1) :- !.
fastfibo(N, X) :-
    N mod 2 =:= 0 ->
        K is N / 2,
        K1 is K - 1,
        fastfibo(K1, X1),
        fastfibo(K, X2),
        X is ((2 * X1) + X2) * X2
    ;
        K is (N + 1) / 2,
        K1 is K - 1,
        fastfibo(K, X1),
        fastfibo(K1, X2),
        X is (X1 * X1) + (X2 * X2).

fibo(N, X) :-
    N >= 0 ->
        fastfibo(N, X)
    ;
        NN is -N,
        fastfibo(NN, Y),
        (N mod 2 =:= 0 -> X is -Y; X is Y).
It calculated and printed fibo(4784969) in about 26 seconds on my RPi3, so Prolog has infinite precision integers (at least swi-prolog does).

Edit:
A few stats, I added the constraint that the result be 1 to prevent the answer being displayed hence it says it is false

Code: Select all

?- time(fibo(4894969,X)), X=1.
% 20,630,877 inferences, 22.953 CPU in 22.970 seconds (100% CPU, 898818 Lips)
false.
She who travels light — forgot something.

Heater
Posts: 12962
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 3:19 pm

Paeryn,

Awesome. That takes 2.9 seconds on my PC. That puts it high up the performance ranking in the fibo(4894969) challenge.

Code: Select all

?- time(fibo(4894969,X)).
% 20,630,877 inferences, 2.938 CPU in 2.940 seconds (100% CPU, 7023277 Lips)
X = 468728969863355...
...
...83322777436978769.

?-
Not sure what I think of it from an expressiveness point of view but it certainly concise.

jalih
Posts: 74
Joined: Mon Apr 15, 2019 3:54 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 4:00 pm

Heater wrote:
Mon Apr 15, 2019 11:17 am
In another desperate attempt to avoid BASIC I spent an couple of hours trying to rise to the fibo(4784969) challenge in YAFL, this time Smalltalk.
I did the same but used 8th programming language:

Code: Select all


\
\ Fibonacci with million digits
\

: fibo-loop
  >r                             \ Put loop counter on r-stack
  \ a b
  2dup 2 n:*                     \ a b a 2b
  over n:-                       \ a b a (2b-a)
  n:* -rot                       \ d=(2b-a)*a a b
  dup n:* swap dup n:* n:+       \ d=(2b-a)*a e=b*b+a*a
  r> [email protected] swap n:shr 1 n:band if
    dup  \ a b b
    rot  \ b b a
    n:+  \ b c=a+b
  then ;


: fibo
  >r    \ Put n on r-stack
  0 1
  ' fibo-loop 0 31 loop-
  rdrop
  drop ;


: app:main
  d:msec >r
  4784969 fibo
  d:msec r> n:- >r
  "%.f" strfmt \ Convert result to just an 'int' string.
  s:len . " digits:" . cr
  dup 40 s:lsub . " upper 40 digits" . cr
  40 s:rsub . " lower 40 digits" . cr
  r> . " msec" . cr
  bye ;
Here is the result on my old desktop machine:

Code: Select all

C:\temp>8th fibo.8th
1000000 digits:
1072739564180047722936481359622500432190 upper 40 digits
3407167474856539211500699706378405156269 lower 40 digits
277 msec

Heater
Posts: 12962
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 6:06 pm

jalih,

Thanks for that.

What is it? Looks like Forth.

We are certainly stepping up the unreadability here.

ejolson
Posts: 3231
Joined: Tue Mar 18, 2014 11:47 am

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 6:33 pm

Paeryn wrote:
Mon Apr 15, 2019 2:38 pm
so Prolog has infinite precision integers (at least swi-prolog does).
It appears Decimal Basic can also run in big-number rational mode and should therefore be suitable for directly computing large Fibonacci numbers using the doubling formulae. While the Karatsuba algorithm is also quite interesting, from a learning point of view, combining Karatsuba with the doubling formula is a project bigger than an hour of code.

Professor John Kemeny foresees IOT, global email, Google search, online shopping and big-data analytics in his 1983 essay The Case for Computer Literacy.

He also envisions things that are yet to come. For example,
Kemeny wrote:The human brain unaided by computers will appear feebleminded.
For me, the most insightful observation is
When beginners say they have trouble learning a computer language, what they really mean is that, although they can learn the language easily enough, expressing their needs in so slight a number of concepts is much more difficult.
Kemeny ends his essay with a statement--although not about Fibonacci numbers--that appears directly relevant to this thread.
One of the oldest dreams of mankind is a universal language. It is notable that computer languages seem to cross national boundaries without difficulty. Thus the first universal language may turn out to be neither English nor Esperanto, but a language like BASIC.
After that transpires, will it still be possible to avoid Basic?
Last edited by ejolson on Mon Apr 15, 2019 6:48 pm, edited 2 times in total.

jalih
Posts: 74
Joined: Mon Apr 15, 2019 3:54 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 6:42 pm

Heater wrote:
Mon Apr 15, 2019 6:06 pm
jalih,

Thanks for that.

What is it? Looks like Forth.

We are certainly stepping up the unreadability here.
Naah, it's readable... After a while your brain adabts and it feels more natural way to code. 8th is like Forth on steroids, it's currently my primary development environment. There is an old thread in these forums about it, but it did not get very welcome reception.

Heater
Posts: 12962
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 6:57 pm

I spent some time trying to adapt my brain to Forth when my brain was a lot more malleable, about 1983. That did not work.

Tried again about 10 years ago. Still no luck.

I get the idea, stack machine and all, but it just seems a really awkward way to write anything. That and the fact that no two Forth variants seem to be compatible.

I'm afraid it's hopeless.

Still, I'll put your entry to the fibo(4784969) challenge up on github with all the others. Sorry "challenge 4784969 fibo".

Is that OK with you?

Heater
Posts: 12962
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 7:07 pm

ejolson,
After that transpires, will it still be possible to avoid Basic?
A bit before Esperanto, in 1880, a certain Johann Martin Schleyer was directed by God, in a dream, to create a universal language. So he did, it was called Volapük.

Volapük became quite popular lots of people learned and spoke it, there were books, meetings and conferences about it. Quite a success. Everyone could see the need for a single standard global language for the peace and prosperity of the world.

But then different groups wanted to adapt the language in different ways. Resulting in in much debate abate and argument. Schleyer himself was against having his creation messed up.

So Volapük splintered, it got forked. Soon nobody was interested in any of the resulting dialects and the whole thing disappeared.

https://en.wikipedia.org/wiki/Volap%C3%BCk

Does this sound familiar?... cough... BASIC.

jalih
Posts: 74
Joined: Mon Apr 15, 2019 3:54 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 7:09 pm

Heater wrote:
Mon Apr 15, 2019 6:57 pm

I get the idea, stack machine and all, but it just seems a really awkward way to write anything. That and the fact that no two Forth variants seem to be compatible.

I'm afraid it's hopeless.

Still, I'll put your entry to the fibo(4784969) challenge up on github with all the others. Sorry "challenge 4784969 fibo".

Is that OK with you?
Luckily 8th also have word local variables and task local variables that ease transition to stack based language, if needed. My first version of the fibo(4784969) abused them heavily.

Code can be used freely.

timrowledge
Posts: 1271
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 9:39 pm

Heater wrote:
Mon Apr 15, 2019 11:29 am
So far I have failed to find any documentation on the limits of GNU Smalltalk Integers.
Normally Smalltalk large integers are limited only by the amount of memory available; they're just damn great arrays of bytes. And in general they are processed with the help of some C code primitives that handle them; so as a benchmark of Smalltalk they're not very interesting.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

timrowledge
Posts: 1271
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 9:58 pm

Heater wrote:
Mon Apr 15, 2019 11:17 am

Code: Select all

Integer extend [
    fibo [ | k fk fk1 | 
        (self < 2)
            ifTrue: [
                ^ self ].
        (self = 2)
            ifTrue: [
                ^ 1
            ].
        (self > 2)
            ifTrue: [
                k := (self + 1) // 2. 
                fk := k fibo.
                fk1 := (k - 1) fibo.
                (self odd)
                    ifTrue: [
                        ^ (fk raisedToInteger: 2) + (fk1 raisedToInteger: 2)
                    ]
                    ifFalse: [
                        ^ ((2 * fk1) + fk) * fk.
                    ]
            ]
    ]
]


My apologies to Smalltalk old hands for my likely bad style and formatting. There does not seem to be anyway to format Smalltalk source nicely.
Wholly Moley, Batman! Now that is some scary code. Why would you be squaring numbers? And halving them? Eek.

A simple recursive fibonacci, apparently correct -

Code: Select all

fib
  ^ self < 2
    ifTrue: [ 1 ]
    ifFalse: [ (self - 2) fib + (self - 1) fib ]
simple iterative fibonacci, apparently correct -
fibIterative
| a b|
a := b := 1.
(self - 1) timesRepeat: [a := b + (b := a)].
^b
[edit: oops, was returning a instead of b. that makes for odd results!]
As previously mentioned in other threads, gst will require some wrapping to make a suitable filein. In a 'real' Smalltalk you use a proper class browser tool that helps you. And a workspace tool that helps you to do... work.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

Heater
Posts: 12962
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 11:34 pm

timrowledge,
Wholly Moley, Batman! Now that is some scary code. Why would you be squaring numbers? And halving them? Eek.
Because if you want to get a million digit Fibonnaci number the recursive algorithm is incredibly slow. The obvious iterative approach is also slow.

This little bit of scary maths gets you there hundreds of times faster. The derivation of it can be found here:
https://www.nayuki.io/page/fast-fibonacci-algorithms
As previously mentioned in other threads, gst will require some wrapping to make a suitable filein. In a 'real' Smalltalk you use a proper class browser tool that helps you. And a workspace tool that helps you to do... work.
The last thing I need in life right now is YAFIDE. Also I'm not convinced it would help much with my problem. Turns out that my GNU Smalltalk is using LargePositiveInteger. Which I can see by doing this:

Code: Select all

8576 fibo class printNl. 
My question then is, why does this produce the wrong answer for 8577? As far as I can tell it is fine below that.

Heater
Posts: 12962
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Mon Apr 15, 2019 11:57 pm

Tim,

If I tweak your fibIterative so that it runs in GNU Smalltalk, like so:

Code: Select all

Integer extend [
    fibIterative [ | a b |
        a := b := 1.
        (self - 1) timesRepeat: [
            a := b + (b := a)
        ].
        ^b
    ]
]

8577 fibIterative printNl.    
It does indeed produce the correct result.

Do I have a bug in my code?

ejolson
Posts: 3231
Joined: Tue Mar 18, 2014 11:47 am

Re: Why Avoid BASIC on RPi?

Tue Apr 16, 2019 12:11 am

Heater wrote:
Mon Apr 15, 2019 11:57 pm
Tim,

If I tweak your fibIterative so that it runs in GNU Smalltalk, like so:

Code: Select all

Integer extend [
    fibIterative [ | a b |
        a := b := 1.
        (self - 1) timesRepeat: [
            a := b + (b := a)
        ].
        ^b
    ]
]

8577 fibIterative printNl.    
It does indeed produce the correct result.

Do I have a bug in my code?
Have you tried squaring fk using fk * fk rather than raising it to the power 2 and the same with fk1?

Heater
Posts: 12962
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Tue Apr 16, 2019 12:16 am

I have now. No change.

User avatar
Paeryn
Posts: 2605
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Why Avoid BASIC on RPi?

Tue Apr 16, 2019 2:02 am

Heater wrote:
Mon Apr 15, 2019 11:17 am

Code: Select all

Integer extend [
    fibo [ | k fk fk1 | 
        (self < 2)
            ifTrue: [
                ^ self ].
        (self = 2)
            ifTrue: [
                ^ 1
            ].
        (self > 2)
            ifTrue: [
                k := (self + 1) // 2. 
                fk := k fibo.
                fk1 := (k - 1) fibo.
                (self odd)
                    ifTrue: [
                        ^ (fk raisedToInteger: 2) + (fk1 raisedToInteger: 2)
                    ]
                    ifFalse: [
                        ^ ((2 * fk1) + fk) * fk.
                    ]
            ]
    ]
]

8576 fibo printNl.    

8576 fibo printNl.
Which produces the correct result up to 8576 under GNU Smalltalk but produces long random numbers after that.
I've just tried it copying it into gst-browser (the GUI) on my RPi3, it correctly calculates 8577 for me. I copy-pasted your code as you gave it so I haven't accidentally corrected anything. Unfortunately VisualGST seems to have problems with the installed GTK+ as some things bring up errors.

I've loaded it straight into gst, same correct result.

Code: Select all

[email protected]:~/Programming/st $ cat heater.st
Integer extend [
        fibo [ | k fk fk1 |
            (self < 2)
                ifTrue: [
                    ^ self ].
            (self = 2)
                ifTrue: [
                    ^ 1
                ].
            (self > 2)
                ifTrue: [
                    k := (self + 1) // 2.
                    fk := k fibo.
                    fk1 := (k - 1) fibo.
                    (self odd)
                        ifTrue: [
                            ^ (fk raisedToInteger: 2) + (fk1 raisedToInteger: 2)
                        ]
                        ifFalse: [
                            ^ ((2 * fk1) + fk) * fk.
                        ]
                ]
    ]
]

8577 fibo printNl.

[email protected]:~/Programming/st $ gst heater.st
"Global garbage collection... done"
13724780954457889052017147206983806244049002655849289934662148526555403650297300643609932653364630032094175733360509578504423049114004867523161091564824674600978308740378989479162611031273424686573759784740689516901416473328655422390895971263265867635819510949686102571388751758998017349379498918930220900180038324615253426530740473855269056304380498630108126734047701362218655030270360608989081398866489746698916626888016696892691933237089180504631788915650757757515944644732966345269202761471025651071790297611079540881155092137592980230998234868586211881093892491570520577408961869977892273540956424095750855208529072246641778982103984467921868950012668004047986803017482248992968482737462668300684879633714025755790485860328854796518843956263863014632532331145699658530054942590047273403691531821918862996422405159427262092477196755988981309029424760342802374213122162727840557722145891090413688461745240415668189577836068480363407847582529735341950500636735281963089675493707159434777756081146452522323681782226760627277553296721358921412115264845467834979154061137421532609247762981818564578019888974692581079593575783553856910367568474613323528337733872069223030834774749130478360574004172522316484339530942110067893000847800932306298725285623628731149337468217751734165148732164148285915275115006479682658150442259002271790547596033006363411193653337536041106069912826015502035140618407668385378737477702597473151509972754111640855347958033314453349633268543893894677097708945041254623018915871109789412793709229204261914803477697183287924195770678873001065036313926288444791424871512110658175954743584548831946767673488152740675550518235698898217693311515366329280005757014637854214769152690638778904780724293185353992279724740604674926819294787586671833537117545443846365508358918882
Ahh... Just ran it on my PC and 8577 gives an incorrect value there, exact same version of gst (3.2.5). I've modified the code so it prints out each step, the PC is getting results wrong starting at fibo(135)

Code: Select all

RPi :-
fibo(135) k = 68 fk  = 72723460248141 fk1 = 44945570212853
7308805952221443105020355490

PC :-
fibo(135) k = 68 fk  = 72723460248141 fk1 = 44945570212853
2020104282444386165882790818
The answer should be (fk * fk) + (fk1 * fk1),

Code: Select all

72723460248141 * 72723460248141 = 5288701670462944237293955881
44945570212853 * 44945570212853 = 2020104281758498867726399609
On the PC the results of the squaring (according to gst) gives

Code: Select all

fk^2  = 685887298156391209
fk1^2 = 2020104281758498867726399609
Clearly the first is very wrong but the second is correct.
Last edited by Paeryn on Tue Apr 16, 2019 3:32 am, edited 3 times in total.
She who travels light — forgot something.

ejolson
Posts: 3231
Joined: Tue Mar 18, 2014 11:47 am

Re: Why Avoid BASIC on RPi?

Tue Apr 16, 2019 3:05 am

Heater wrote:
Tue Apr 16, 2019 12:16 am
I have now. No change.
Could the problem be related to Linux subsystem for Windows?

User avatar
John_Spikowski
Posts: 1308
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Tue Apr 16, 2019 3:07 am

Any chance of seeing a BASIC to 8th translator? ;)

Return to “Off topic discussion”