Bug?

Anything QL Software or Programming Related.
Post Reply
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Bug?

Post by pjw »

Can anyone tell me whats going on here:

Code: Select all

a = 2^32: b = -2^32: PRINT a = b, a, b
a = 2^32: b = -(2^32): PRINT a = b, a, b
?!
To me it seems like the first result is wrong. The second line produces the result Id expect from line one.
Latest SMSQ/E and Qdos JS both display the same behaviour.


Per
dont be happy. worry
- ?
User avatar
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

Re: Bug?

Post by Andrew »

pjw wrote:Can anyone tell me whats going on here:

Code: Select all

a = 2^32: b = -2^32: PRINT a = b, a, b
a = 2^32: b = -(2^32): PRINT a = b, a, b
?!
To me it seems like the first result is wrong. The second line produces the result Id expect from line one.
Latest SMSQ/E and Qdos JS both display the same behaviour.
The results are both correct.
-2 raised to any even power will be positive.
QL interprets -2^N as (-2)^N (as a single operation with 2 operands), while -(2^32) is actually 2 operations - first the raise to power and then the sign change
try

Code: Select all

for i=1 to 10: print -2^i: next i
Also notice the difference

Code: Select all

print 8-2^2
print 8+-2^2
In first case the minus is not the sign of the number 2, but the substraction operation
In second case the minus is the sign of the number


User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Bug?

Post by pjw »

Whoops! A bit of late Friday night brain fog!
Thanks, Andrew, for your patience :)
There were reasons why I stumbled down this particular rabbit hole. But since no actual rabbits were found I shant waste any more time with excuses or explanations.


Per
dont be happy. worry
- ?
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Bug?

Post by pjw »

I was testing a program that worked fine on my QPC2 and SMSQmulator
setups, but crashed on Q-Emulator both with Qdos and Minerva with
TK2-2.32. To boil it down to basics this is what I found:

Code: Select all

ch = fopen('win1_test_bin')
get#ch\ 322: print fpos(#ch)
On JS it printed 382, and on Minerva 352; the correct answer should,
of course, be 322!
Is this a QL, TK2, or a Q-Emulator issue? I dont have any real QL
hardware to test on, so could someone please oblige and tell me where
the problem is?


Per
dont be happy. worry
- ?
User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Bug?

Post by mk79 »

pjw wrote:Is this a QL, TK2, or a Q-Emulator issue? I dont have any real QL hardware to test on, so could someone please oblige and tell me where the problem is?
As far as I can see this is a QemuLator bug that only happens when the drive is mapped to a Windows directory and the file is one with a QemuLator header attached.


User avatar
XorA
Site Admin
Posts: 1359
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: Bug?

Post by XorA »

mk79 wrote:
pjw wrote:Is this a QL, TK2, or a Q-Emulator issue? I dont have any real QL hardware to test on, so could someone please oblige and tell me where the problem is?
As far as I can see this is a QemuLator bug that only happens when the drive is mapped to a Windows directory and the file is one with a QemuLator header attached.
Gah another corner case I now need to check!


User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Bug?

Post by pjw »

mk79 wrote:
pjw wrote:Is this a QL, TK2, or a Q-Emulator issue? I dont have any real QL hardware to test on, so could someone please oblige and tell me where the problem is?
As far as I can see this is a QemuLator bug that only happens when the drive is mapped to a Windows directory and the file is one with a QemuLator header attached.
Thanks for checking, Marcel. I guess I shouldve done that myself before asking questions, but I was in the middle of something and then got stomped by this so moved on to something else hoping to have a solution by the time I returned..


Per
dont be happy. worry
- ?
Derek_Stewart
Font of All Knowledge
Posts: 3931
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Bug?

Post by Derek_Stewart »

Or maybe this is a feature, it seems Windows is packed with features...


Regards,

Derek
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: Bug?

Post by pjw »

XorA wrote:
mk79 wrote:
pjw wrote:Is this a QL, TK2, or a Q-Emulator issue? I dont have any real QL hardware to test on, so could someone please oblige and tell me where the problem is?
As far as I can see this is a QemuLator bug that only happens when the drive is mapped to a Windows directory and the file is one with a QemuLator header attached.
Gah another corner case I now need to check!
Its vital that systems work the same way across the board so pleeease fix if needed and possible!
To my mind there should also be a common command across the board that can be queried to see which platform one is on. Eg PRINT PLATFORM$: 0001101001100101 (or whatever) with a dummy toolkit for QLs, with parameters set by users who know whether they have a (S)GC, SuperHermes, or whatever. Another is EMU_VER$ (or whatever). I know that a lot can be gleaned from the sysvars, but some platforms pride themselves on QL emulation, while in reality they sport important differences.
A case in point is my attempt to make a game that adapts itself to run on all platforms (WQRDLI). Its almost impossible! My "Bug?" query above arose from (the failure of) that attempt.
I cringe at the thought of newcomers or returnees trying to make sense out of this whole mess! Nice and valiant as, for example, QL/E is, a lot of programs just dont work "out of the box", and even I, a long-serving old-timer, dont know how (or cant be bothered) to try to fix them! Of course, most old programs have to be left to their fate, but at least new ones should be given a chance..


Per
dont be happy. worry
- ?
User avatar
XorA
Site Admin
Posts: 1359
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: Bug?

Post by XorA »

Its vital that systems work the same way across the board so pleeease fix if needed and possible!
sQLux doesnt currently seem to suffer!


Post Reply