### Author Topic: What Happened?  (Read 923 times)

#### B+

• Hero Member
• Posts: 846
##### What Happened?
« on: 30. August 2018, 03:52:32 »
Hi Chris,

Do you know why this no longer works?
Code: [Select]
`for i in seq(0, 2*pi, 360/15+1) do ? round(deg(i)), ((10000*sin(i))\1)*.0001`
At one time it printed out a SIN table, every 15 degrees.

#### chrisws

• Moderator
• Newcomer
• Posts: 38
##### Re: What Happened?
« Reply #1 on: 30. August 2018, 12:32:02 »
It's a subtle bug related to internal data types. I was going to release an update sometime soon, so can include the fix.

Cheers,
Chris

#### B+

• Hero Member
• Posts: 846
##### Re: What Happened?
« Reply #2 on: 30. August 2018, 14:32:22 »
OK

BTW I should mention the version 0,12,11 SDL Win 64 Dec 28, 2017.

I probably wrote the original line of code (mod by jasali) with version 12.9 or earlier.

#### ScriptBasic

• Guest
##### Re: What Happened?
« Reply #3 on: 30. August 2018, 19:17:28 »
Chris,

Let me know if there is anything you need to support your board on the All BASIC forum.

#### B+

• Hero Member
• Posts: 846
##### Re: What Happened? Fixed in SmallBASIC 0.12.13
« Reply #4 on: 13. September 2018, 17:01:53 »
Fixed!
Code: [Select]
`REM SmallBASIC "One statement SIN test"REM created: 13/09/2018 seq test.bas B+for i in seq(0, 360, 25) do ? "i = ";i;", rad(i) = ";rad(i);", sin(rad(i)) = ";sin(rad(i))`
So do you like the labeled Table?

#### B+

• Hero Member
• Posts: 846
##### Re: What Happened?
« Reply #5 on: 28. October 2018, 17:08:59 »
What happened to SmallBASIC's Random number generator? Was it always this bad?

Here I was testing 1,000,000 random numbers * 1000000 to compare Sort methods, and did not get much variation!
Code: [Select]
`REM SmallBASICREM created: 28/10/2018'Compare RussianSorting presented by Danilin to a Basic standard QuickSort by B+ 2018-10-28"RANDOMIZE TIMER' Here is the only relevant parts of DanilinCONST n = 1000000DIM d(n) ' singleDIM a(n) ' singleDIM QS(n) ' to compare to Danilin's "simple" code' Make a sample set of test dataFOR i = 1 TO n    r = RND * n    d(i) = r    QS(i) = rNEXT' Since Danilin does not provide us with "c:/N.txt" file data, can't be important to his demoage = 1 + LOG(n) / LOG(2)start = TIMERIF age > 0 THEN    RussianSortingHalvesDAV 1, n, 1, ageEND IFfinish = TIMERPRINT finish - start; "second "IF n > 100 THEN stopper = 100 ELSE stopper = nFOR i = 1 TO stopper    PRINT d(i); ", ";NEXTDanilinTime = finish - startPRINT: PRINT: INPUT "Now for the Quick Sort Test, press enter...", enter\$CLS'now try good ole Quick Sortstart = TIMERqSort 1, nfinish = TIMERPRINT finish - start; "sec."IF n > 100 THEN stopper = 100 ELSE stopper = nFOR i = 1 TO stopper    PRINT d(i); ", ";NEXTQSortTime = finish - startPRINT: PRINT: PRINT "Ha, ha, ha QSort took "; INT(QSortTime / DanilinTime * 1000) / 1000; " times longer than Danilin's Sort!"PAUSESUB RussianSortingHalvesDAV (ab, yz, part, age)  local i, summa, middle, abc, xyz    IF yz - ab < 1 THEN EXIT SUB    FOR i = ab TO yz '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> really a time waster and String Array Buster here!!!!!        summa = summa + d(i)    NEXT    middle = summa / (yz - ab + 1)    abc = ab - 1    xyz = yz + 1    FOR i = ab TO yz        IF d(i) < middle THEN abc = abc + 1: a(abc) = d(i): ELSE xyz = xyz - 1: a(xyz) = d(i)    NEXT    FOR i = ab TO yz: d(i) = a(i): NEXT    IF part < age THEN        IF abc >= ab THEN RussianSortingHalvesDAV ab, abc, part + 1, age        IF xyz <= yz THEN RussianSortingHalvesDAV xyz, yz, part + 1, age    END IFEND SUB'QS is DIM SHARED to compare to Danilin's method that needs two DIM SHARED Arrays for his SUBSUB qSort (start, finish)  local Hi, Lo, Middle    'DIM Hi AS LONG, Lo AS LONG, Middle AS SINGLE    Hi = finish: Lo = start    Middle = QS((Lo + Hi) / 2) 'find middle of array    REPEAT        WHILE QS(Lo) < Middle: Lo = Lo + 1: WEND        WHILE QS(Hi) > Middle: Hi = Hi - 1: WEND        IF Lo <= Hi THEN            SWAP QS(Lo), QS(Hi)            Lo = Lo + 1: Hi = Hi - 1        END IF    UNTIL Lo > Hi    IF Hi > start THEN qSort start, Hi    IF Lo < finish THEN qSort Lo, finishEND SUB`
You can see the repetition of values in first 100 after sort. Jump from <1 to 30.xxx
« Last Edit: 28. October 2018, 19:03:49 by B+ »