adesutherland / CMS-370-BREXX

VM/370 Port of BREXX
Other
7 stars 5 forks source link

X2D Test Failure #36

Open adesutherland opened 4 years ago

adesutherland commented 4 years ago
2020-05-11T08:46:33.3314788Z Look for X2D OK
2020-05-11T08:46:33.3314889Z failed in test 68
2020-05-11T08:46:33.3315149Z 80 *-* if x2d(+1E+2) \== '256'
2020-05-11T08:46:33.3315264Z Error 15 running x2d_, line 80: Invalid hexadecimal or binary string
2020-05-11T08:46:33.3315387Z WARNING: MEMORY FREED (40 BYTES LEAKED)
2020-05-11T08:46:33.3315632Z 82 *-* interpreter ' x2d_'||suffix
2020-05-11T08:46:33.3315723Z +++ RC(15) +++
adesutherland commented 3 years ago

@rvjansen Rene - can you explain what +1E+2 means - how to we get to 256? Thanks A

RexxLA commented 3 years ago

on VM, this returns 0.

a = x2d(+1E+2) say a -> 256. So hex 1E2 converted to dec gives 256. I'll elaborate on that when I had coffee and my work meeting is ended this afternoon.

adesutherland commented 3 years ago

Is the + like a space, i.e. something that should be ignored? What other chars should be ignored e.g. dash - ?

RexxLA commented 3 years ago
 3 *-* say x2d(+1E+2) \== '256'                                        
   >L>   "1E+2"                                                        
   >P>   "100"                                                         
   >F>   "256"                                                         
   >L>   "256"                                                         
   >O>   "0"                                                           

0
4 - say x2d(-1E+2) \== '256'

L> "1E+2"
P> "-100"
4 +++ say x2d(-1E+2) \== '256'
DMSREX475E Error 40 running HEXERR EXEC, line 4: Incorrect call to routine

So, the first plus sign can be ignored. We have 1E2, which is scientific form for 100, which is decimal 256. It cannot be a minus sign.

The difficult one I find is when space is ignored, but when an X is in play, the first part is ignored:

11 *-* say x2d('c6 f0'x)  
   >L>   "F0"             
   >F>   "240"            

240
12 - say x2d('c6 f0')

L> "c6 f0"
F> "50928"
50928
13 - say x2d('c6f0')
L> "c6f0"
F> "50928"
50928

RexxLA commented 3 years ago

and the backgrounds are github's, not mine

adesutherland commented 3 years ago

Thanks very much

11 - say x2d('c6 f0'x)

L> "F0"
F> "240"

Must therefore be a bug in the original REXX?


I am not convinced people really expect 1E+2 to mean 100x!! But OK, whatever, I will try and fix :-)

Also I notice that spaces in the hex string seem broken - so will look to fix at the same time (however probably with 'c6 f0'x ='c6f0'x )


After the X2D fix, I will cut a BREXX release and spend the next week on CREXX stuff

rvjansen commented 3 years ago

Funny thing is, it is in the book:

René.

On 6 Nov 2020, at 21:34, Adrian Sutherland notifications@github.com wrote:

 Thanks very much

11 - say x2d('c6 f0'x)

L> "F0" F> "240"

Must therefore be a bug in the original REXX?

I am not convinced people really expect 1E+2 to mean 100x!! But OK, whatever, I will try and fix :-)

Also I notice that spaces in the hex string seem broken - so will look to fix at the same time (however probably with 'c6 f0'x ='c6f0'x )

After the X2D fix, I will cut a BREXX release and spend the next week on CREXX stuff

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

RexxLA commented 3 years ago

5D3DAE48-7DB4-4B85-B0F1-95B90C96EFB2

adesutherland commented 3 years ago

Yes - and in fact it seems to work in BREXX - don't know why!

Can you check rexxtry with real rexx

say 12E7 + 1
120000001
Rexxtry;
say 12E7 + 0
12
Rexxtry;
say 12E7 12E7
Rexxtry;

Thanks A

rvjansen commented 3 years ago

I had to find a suitable rexxtry exec first, but here they are:

Ready; T=0.04/0.08 01:17:49
rexxtry
REXXTRY lets you interactively try REXX statements.
Each string is executed when you hit Enter.
Enter 'call tell' for a description of the features.
Go on - try a few... Enter 'exit' to end.
say 12e7+1
120000001
..................................................... REXXTRY on CMS
say 12e7 + 0
120000000
..................................................... REXXTRY on CMS
say 12e7
12E7
..................................................... REXXTRY on CMS

best regards,

René.

On 6 Nov 2020, at 22:52, Adrian Sutherland notifications@github.com wrote:

Yes - and in fact it seems to work in BREXX - don't know why!

Can you check rexxtry with real rexx

say 12E7 + 1 120000001 Rexxtry; say 12E7 + 0 12 Rexxtry; say 12E7 12E7 Rexxtry;

Thanks A

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723316490, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3WJQMU6VQYB667SD3NJPTSORV3VANCNFSM4M52IOEQ.

adesutherland commented 3 years ago

Rene - this might sound very very pedantic - but in my defense we are talking about the scientific format for base 16 ... (which is weird)

So

1/ Is '1E+1'x == '10'x - ( ditto for X2D('1E+1') )

2/ Is '1E+A'x valid and == '10000000000'x (decimal 10 zeros)

3/ is '1E+10' valid and == '10000000000000000'x (decimal 16 zeros)

In sum, is the exponent a base 16 number?

Is there a Rexx document covering this?

Adrian

rvjansen commented 3 years ago

Hi Adrian,

I assume you have this https://archive.org/details/TheRexxLanguage-APracticalApproachToProgramming2ndEdition/page/n1/mode/2up https://archive.org/details/TheRexxLanguage-APracticalApproachToProgramming2ndEdition/page/n1/mode/2up

The description is not particularly clear. I must admit I always used this from copy and paste fo working cases and did never worry too much.

Within the context of X2D it certainly seems a hex number in exponential notation. This is how the 1E2 becomes X’100’ and then 256. But exponential notation (scientific and engineering) in other contexts is decimal; I never saw this example of it being used in hex (but why not?).

The example with the space in it I only began to understand after something Walter said:

11 - say x2d('c6 f0'x)
the x in play makes the Argument a string of 2 characters neither of which is in the range 0-9 a-f (in ASCII) I would expect this to work on CMS

Try trace ?I z=x2c('c6 f0'x) say c2x(z) z=x2c('46 30'x) say c2x(z)

 3 *-* z=x2c('c6 f0'x)                                                      
   >L>   "F0"                                                               
   >F>   "0"                                                                
   +++ Interactive trace.  TRACE OFF to end debug, ENTER to continue. +++   

 4 *-* say c2x(z)                                                           
   >V>   "0"                                                                
   >F>   "F0"                                                               

F0

 5 *-* z=x2c('46 30'x)                                                      
   >L>   "ã?"                                                               
 5 +++ z=x2c('46 30'x)                                                      

DMSREX475E Error 40 running XTEST EXEC, line 5: Incorrect call to routine
Ready(20040); T=0.01/0.03 11:41:50

I was not able to use another instance of base-16 exponential notation, so this stays murky for me and needs some more investigation.

René.

On 7 Nov 2020, at 22:29, Adrian Sutherland notifications@github.com wrote:

Rene - this might sound very very pedantic - but in my defense we are talking about the scientific format for base 16 ... (which is weird)

So

1/ Is '1E+1'x == '10'x - ( ditto for X2D('1E+1') )

2/ Is '1E+A'x valid and == '10000000000'x (decimal 10 zeros)

3/ is '1E+10' valid and == '10000000000000000'x (decimal 16 zeros)

In sum, is the exponent a base 16 number?

Is there a Rexx document covering this?

Adrian

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723497648, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3WJQIKBWAU73JARBHYEPDSOW33XANCNFSM4M52IOEQ.

adesutherland commented 3 years ago

Thanks for the explanation ... I think I understand that now (strings in strings, is how I am thinking of it).

Can you check what x2c('1E+A') does on real VM. Is it an invalid hex or perhaps it just works!

I think that the exponent should be decimal, so that is what I will do unless your test implies otherwise. Also there is a section here https://en.m.wikipedia.org/wiki/Scientific_notation that implies H should be used instead of E for a hex exponent value.

I suspect this wasn't thought through to hard back in the day when rexx was first done!

A

On Sun, 8 Nov 2020, 11:15 René Vincent Jansen, notifications@github.com wrote:

Hi Adrian,

I assume you have this https://archive.org/details/TheRexxLanguage-APracticalApproachToProgramming2ndEdition/page/n1/mode/2up < https://archive.org/details/TheRexxLanguage-APracticalApproachToProgramming2ndEdition/page/n1/mode/2up>

The description is not particularly clear. I must admit I always used this from copy and paste fo working cases and did never worry too much.

Within the context of X2D it certainly seems a hex number in exponential notation. This is how the 1E2 becomes X’100’ and then 256. But exponential notation (scientific and engineering) in other contexts is decimal; I never saw this example of it being used in hex (but why not?).

The example with the space in it I only began to understand after something Walter said:

11 - say x2d('c6 f0'x) the x in play makes the Argument a string of 2 characters neither of which is in the range 0-9 a-f (in ASCII) I would expect this to work on CMS

Try trace ?I z=x2c('c6 f0'x) say c2x(z) z=x2c('46 30'x) say c2x(z)

3 - z=x2c('c6 f0'x)

L> "F0" F> "0" +++ Interactive trace. TRACE OFF to end debug, ENTER to continue. +++

4 - say c2x(z)

V> "0" F> "F0" F0

5 - z=x2c('46 30'x)

L> "ã?" 5 +++ z=x2c('46 30'x) DMSREX475E Error 40 running XTEST EXEC, line 5: Incorrect call to routine Ready(20040); T=0.01/0.03 11:41:50

I was not able to use another instance of base-16 exponential notation, so this stays murky for me and needs some more investigation.

René.

On 7 Nov 2020, at 22:29, Adrian Sutherland notifications@github.com wrote:

Rene - this might sound very very pedantic - but in my defense we are talking about the scientific format for base 16 ... (which is weird)

So

1/ Is '1E+1'x == '10'x - ( ditto for X2D('1E+1') )

2/ Is '1E+A'x valid and == '10000000000'x (decimal 10 zeros)

3/ is '1E+10' valid and == '10000000000000000'x (decimal 16 zeros)

In sum, is the exponent a base 16 number?

Is there a Rexx document covering this?

Adrian

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723497648>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AC3WJQIKBWAU73JARBHYEPDSOW33XANCNFSM4M52IOEQ .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723562580, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBKI6TH42OHIXLBIMLAV5DSOZ4UZANCNFSM4M52IOEQ .

adesutherland commented 3 years ago

PS. I have an old copy of that book :-) I was just wondering if the standards folks formalised it!

On Sun, 8 Nov 2020, 11:15 René Vincent Jansen, notifications@github.com wrote:

Hi Adrian,

I assume you have this https://archive.org/details/TheRexxLanguage-APracticalApproachToProgramming2ndEdition/page/n1/mode/2up < https://archive.org/details/TheRexxLanguage-APracticalApproachToProgramming2ndEdition/page/n1/mode/2up>

The description is not particularly clear. I must admit I always used this from copy and paste fo working cases and did never worry too much.

Within the context of X2D it certainly seems a hex number in exponential notation. This is how the 1E2 becomes X’100’ and then 256. But exponential notation (scientific and engineering) in other contexts is decimal; I never saw this example of it being used in hex (but why not?).

The example with the space in it I only began to understand after something Walter said:

11 - say x2d('c6 f0'x) the x in play makes the Argument a string of 2 characters neither of which is in the range 0-9 a-f (in ASCII) I would expect this to work on CMS

Try trace ?I z=x2c('c6 f0'x) say c2x(z) z=x2c('46 30'x) say c2x(z)

3 - z=x2c('c6 f0'x)

L> "F0" F> "0" +++ Interactive trace. TRACE OFF to end debug, ENTER to continue. +++

4 - say c2x(z)

V> "0" F> "F0" F0

5 - z=x2c('46 30'x)

L> "ã?" 5 +++ z=x2c('46 30'x) DMSREX475E Error 40 running XTEST EXEC, line 5: Incorrect call to routine Ready(20040); T=0.01/0.03 11:41:50

I was not able to use another instance of base-16 exponential notation, so this stays murky for me and needs some more investigation.

René.

On 7 Nov 2020, at 22:29, Adrian Sutherland notifications@github.com wrote:

Rene - this might sound very very pedantic - but in my defense we are talking about the scientific format for base 16 ... (which is weird)

So

1/ Is '1E+1'x == '10'x - ( ditto for X2D('1E+1') )

2/ Is '1E+A'x valid and == '10000000000'x (decimal 10 zeros)

3/ is '1E+10' valid and == '10000000000000000'x (decimal 16 zeros)

In sum, is the exponent a base 16 number?

Is there a Rexx document covering this?

Adrian

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723497648>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AC3WJQIKBWAU73JARBHYEPDSOW33XANCNFSM4M52IOEQ .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723562580, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBKI6TH42OHIXLBIMLAV5DSOZ4UZANCNFSM4M52IOEQ .

rvjansen commented 3 years ago

That is an invalid hex string.

 3 *-* SAY X2C('1E+A')                                                            
   >L>   "1E+A"                                                                   
 5 +++  a ='1e+2'x                                                                
 3 +++ SAY X2C('1E+A')                                                            

DMSREX462E Error 15 running ETEST EXEC, line 5: Invalid hexadecimal or binary string

On 8 Nov 2020, at 13:34, Adrian Sutherland notifications@github.com wrote:

x2c('1E+A')

RexxLA commented 3 years ago

Ok, let’s compare what NetRexx does:

Ready; say '1e2'.x2d() 0.040 s 482 Ready; say '100'.x2d() 0.039 s 256 Ready; say '1e+2'.x2d() 0.043 s Throwable:netrexx.lang.BadArgumentException: Bad hexadecimal 1e+2 Ready; say '+1e+2'.x2d() 0.040 s Throwable:netrexx.lang.BadArgumentException: Bad hexadecimal +1e+2 Ready;

I think the parsing of +1e+2 as 100 in classic rexx is just a fluke, as -1e+2 fails. It seems to be fixed in NetRexx.

René.

On 8 Nov 2020, at 15:55, René Vincent Jansen notifications@github.com wrote:

That is an invalid hex string.

3 - SAY X2C('1E+A')

L> "1E+A" 5 +++ a ='1e+2'x 3 +++ SAY X2C('1E+A') DMSREX462E Error 15 running ETEST EXEC, line 5: Invalid hexadecimal or binary string

On 8 Nov 2020, at 13:34, Adrian Sutherland notifications@github.com wrote:

x2c('1E+A')

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723588160, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7JABA626VYSQAW3XDTOITSO2WNRANCNFSM4M52IOEQ.

rvjansen commented 3 years ago

for reference, this is what NetRexx does

/* X2d.
Arg1 is hexstring to convert.
Arg2 is N (-1 if not specified)
returns char[]
/ method x2d(x=Rexx, n=int) constant returns char[] / see if we're a negative, and decide where to start / neg=boolean 0 -- assume non-negative select when n=0 | x.chars.length=0 then return char[] '0' when n<0 then start=0 / n>0 / when n>x.chars.length then start=0 otherwise -- n is in string start=x.chars.length-n if x.chars[start]>'7' | x.chars[start]<'0' then neg=1 -- baddies caught later end / determine a safe DIGITS / digs=x.chars.length*5%4+1 if digs>Rexx.DefaultDigits then set=RexxSet(digs) else set=null work=Rexx(int 0) -- accumulator loop i=start to x.chars.length-1 -- from the left nibble=hexint(x.chars[i]) if nibble<0 then signal BadArgumentException("Bad hexadecimal" x) if neg then nibble=15-nibble work=work.OpMult(set, sixteen).OpAdd(set, Rexx(nibble)) end i if neg then work=work.OpAdd(set, one).OpMinus(set) return char[] work

In any case, it flags the invalid hex string, and I think that is what CREXX should do.

René.

On 8 Nov 2020, at 17:08, Rexx Language Association notifications@github.com wrote:

Ok, let’s compare what NetRexx does:

Ready; say '1e2'.x2d() 0.040 s 482 Ready; say '100'.x2d() 0.039 s 256 Ready; say '1e+2'.x2d() 0.043 s Throwable:netrexx.lang.BadArgumentException: Bad hexadecimal 1e+2 Ready; say '+1e+2'.x2d() 0.040 s Throwable:netrexx.lang.BadArgumentException: Bad hexadecimal +1e+2 Ready;

I think the parsing of +1e+2 as 100 in classic rexx is just a fluke, as -1e+2 fails. It seems to be fixed in NetRexx.

René.

On 8 Nov 2020, at 15:55, René Vincent Jansen notifications@github.com wrote:

That is an invalid hex string.

3 - SAY X2C('1E+A')

L> "1E+A" 5 +++ a ='1e+2'x 3 +++ SAY X2C('1E+A') DMSREX462E Error 15 running ETEST EXEC, line 5: Invalid hexadecimal or binary string

On 8 Nov 2020, at 13:34, Adrian Sutherland notifications@github.com wrote:

x2c('1E+A')

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723588160, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7JABA626VYSQAW3XDTOITSO2WNRANCNFSM4M52IOEQ.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723607706, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3WJQNDNV7JENPXCYL2YOTSO27BRANCNFSM4M52IOEQ.

adesutherland commented 3 years ago

Well I am just implementing it :-(

Oh well ... we can experiment with different options and see what makes sense :-)

I do agree that it probably was a parsing error in classic rexx, perhaps ...

Personally for hex strings something like 1AHE1 == 0x1A * (0xF to the power of 0xE1) makes most sense. But that's for discussion!

But anyway onwards and upwards!

Adrian

On Sun, 8 Nov 2020, 16:22 René Vincent Jansen, notifications@github.com wrote:

for reference, this is what NetRexx does

/* X2d.
Arg1 is hexstring to convert.
Arg2 is N (-1 if not specified)
returns char[]
/ method x2d(x=Rexx, n=int) constant returns char[] / see if we're a negative, and decide where to start / neg=boolean 0 -- assume non-negative select when n=0 | x.chars.length=0 then return char[] '0' when n<0 then start=0 / n>0 / when n>x.chars.length then start=0 otherwise -- n is in string start=x.chars.length-n if x.chars[start]>'7' | x.chars[start]<'0' then neg=1 -- baddies caught later end / determine a safe DIGITS / digs=x.chars.length*5%4+1 if digs>Rexx.DefaultDigits then set=RexxSet(digs) else set=null work=Rexx(int 0) -- accumulator loop i=start to x.chars.length-1 -- from the left nibble=hexint(x.chars[i]) if nibble<0 then signal BadArgumentException("Bad hexadecimal" x) if neg then nibble=15-nibble work=work.OpMult(set, sixteen).OpAdd(set, Rexx(nibble)) end i if neg then work=work.OpAdd(set, one).OpMinus(set) return char[] work

In any case, it flags the invalid hex string, and I think that is what CREXX should do.

René.

On 8 Nov 2020, at 17:08, Rexx Language Association < notifications@github.com> wrote:

Ok, let’s compare what NetRexx does:

Ready; say '1e2'.x2d() 0.040 s 482 Ready; say '100'.x2d() 0.039 s 256 Ready; say '1e+2'.x2d() 0.043 s Throwable:netrexx.lang.BadArgumentException: Bad hexadecimal 1e+2 Ready; say '+1e+2'.x2d() 0.040 s Throwable:netrexx.lang.BadArgumentException: Bad hexadecimal +1e+2 Ready;

I think the parsing of +1e+2 as 100 in classic rexx is just a fluke, as -1e+2 fails. It seems to be fixed in NetRexx.

René.

On 8 Nov 2020, at 15:55, René Vincent Jansen notifications@github.com wrote:

That is an invalid hex string.

3 - SAY X2C('1E+A')

L> "1E+A" 5 +++ a ='1e+2'x 3 +++ SAY X2C('1E+A') DMSREX462E Error 15 running ETEST EXEC, line 5: Invalid hexadecimal or binary string

On 8 Nov 2020, at 13:34, Adrian Sutherland notifications@github.com wrote:

x2c('1E+A')

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723588160>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AC7JABA626VYSQAW3XDTOITSO2WNRANCNFSM4M52IOEQ .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723607706>, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AC3WJQNDNV7JENPXCYL2YOTSO27BRANCNFSM4M52IOEQ .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adesutherland/CMS-370-BREXX/issues/36#issuecomment-723618005, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBKI6Q7G6T2422X46VZP2LSO3AUBANCNFSM4M52IOEQ .

adesutherland commented 3 years ago

I've completely misunderstood the problem here - age - and created a weird hex parser than accepts '1E+2' as hex string. Total waste of time! The real problem is the expression parser does not convert 1E+2 to 100 and then to the string '100' allowing X2D to convert to 256. And re-reading the thread it was because I didn't read what Rene was saying carefully enough! What a waste of time!! Oh well :-)

adesutherland commented 3 years ago

The root cause is that BREXX does not implement the unary plus properly (currently it ignores it, but it should be triggering a change to numeric, i.e like X+0). Will add this.

This change will be a good candidate for applying upstream

adesutherland commented 3 years ago

The two errors remaining are:

adesutherland commented 3 years ago

Final issues (Error 77) fixed in F0037

mgrossmann commented 3 years ago

quick test: (did not really understood the problem, but the fix for error 77 seems to work)

Ready(brexx);     
say X2D('abc',0)  
0                 
Ready(brexx);