Re: signum

2013-10-23 Thread Rob van der Heij
On 24 October 2013 02:42, Tony Harminc wrote: On 23 October 2013 19:43, Paul Gilmartin wrote: > > I have occasionally gotten > > flamboyant and coded such as: > > > > X = copies( 'gubbins', A==B ) /* instead of: */ > > > > if A==B > > then X = 'gubbins' > > else X = ''

Re: Linear search vs binary

2013-10-23 Thread Rob van der Heij
On 24 October 2013 02:43, Paul Gilmartin wrote: > > The search may be terminated early (however infrequently) on > discovering an exact match. But this requires an extra comparison > if ternary results are unavailable (as they are in assembler -- > is that sufficiently on-topic?) The cost of th

Re: Why is division by zero permitted?

2013-10-23 Thread glen herrmannsfeldt
>From C28-6514-5 on bitsavers, on page 16: "Division by zero is permitted and yields a zero result." After that, (and presumably also earlier) it has to stay that way as code (macros) might depend on that. There is no reason given. -- glen

Re: Why is division by zero permitted?

2013-10-23 Thread Jon Perryman
What arithmetic expression allows divide by 0? Jon Perryman. > > From: Paul Gilmartin > >OK. Pure HLASM. I've long wondered why division by zero is permitted >in arithmetic expressions when otherwise overflows (even in division) >are reported as errors. > >The o

Re: Why is division by zero permitted?

2013-10-23 Thread Blaicher, Christopher Y.
Never has been allowed. From the POPS for all integer divide instructions: When the divisor is zero, or when the magnitudes of the dividend and divisor are such that the quotient cannot be expressed by a 32-bit signed binary integer, a fixed-point-divide exception is recognized. This includes the

Re: Why is division by zero permitted?

2013-10-23 Thread robin
From: "Paul Gilmartin" Sent: Thursday, October 24, 2013 11:30 AM OK. Pure HLASM. I've long wondered why division by zero is permitted It is? According to my manual, the operation is suppressed, and an exception occurs. in arithmetic expressions when otherwise overflows (even in division

Re: signum

2013-10-23 Thread robin
From: "Paul Gilmartin" Sent: Thursday, October 24, 2013 11:51 AM On 2013-10-23 18:36, robin wrote: Any overflow is detected. And anyway, how do you think that J > K is computed? The comparison is performed by subtracting K from J (without changing either J or K, of course). Why not use t

Re: signum

2013-10-23 Thread Paul Gilmartin
On 2013-10-23 18:36, robin wrote: > > Any overflow is detected. > > And anyway, how do you think that J > K is computed? > > The comparison is performed by subtracting K from J > (without changing either J or K, of course). Why not use the Compare instruction? (As in Assembler -- on-topic.) -- g

Re: Why is division by zero permitted?

2013-10-23 Thread Kurt LeBesco
Sounds like a plausible answer! My guess would be that IBM thought assembler programmers sufficiently Intelligent so as to avoid doing that! On Oct 23, 2013 8:31 PM, "Paul Gilmartin" wrote: > On 2013-10-23 17:54, Kurt LeBesco wrote: > > I've been reading quietly and wondering how the dialog drift

Re: Linear search vs binary

2013-10-23 Thread Paul Gilmartin
On 2013-10-23 17:51, robin wrote: >>> >> ... the value of comparison operands [operators -- gil] having >> a ternary result. Of course this is available in (zSeries) >> assembler. It might typically shorten a table search by one >> iteration. > > How is that? > The search may be terminated early

Re: signum

2013-10-23 Thread Tony Harminc
On 23 October 2013 19:43, Paul Gilmartin wrote: > I have occasionally gotten > flamboyant and coded such as: > > X = copies( 'gubbins', A==B ) /* instead of: */ > > if A==B > then X = 'gubbins' > else X = '' That's a very APLish thing to do. Tony H.

Re: signum

2013-10-23 Thread robin
From: "Paul Gilmartin" Sent: Thursday, October 24, 2013 10:47 AM On 2013-10-23 17:33, robin wrote: What? Rexx'sm = ( j > k ) - ( j < k ); would be exactly the same in PL/I. However, you would never write it like that. It's just obfuscation. simplest (and trivial-est) in PL/I is m = si

Re: Linear search vs binary

2013-10-23 Thread Alan Atkinson
Glad you got some use out of it. It's a pretty simplistic implementation, but sufficient for our needs. Although based on how rapidly the discussion veered into other languages I thought I'd missed your point somehow. Sent from my iPad > On Oct 23, 2013, at 9:43 AM, "Dougie Lawson" wrote: >

Why is division by zero permitted?

2013-10-23 Thread Paul Gilmartin
On 2013-10-23 17:54, Kurt LeBesco wrote: > I've been reading quietly and wondering how the dialog drifted off to rexx > and pl1 land. Can we get back on topic? Thanks > OK. Pure HLASM. I've long wondered why division by zero is permitted in arithmetic expressions when otherwise overflows (even in

Re: signum

2013-10-23 Thread robin
- Original Message - From: "Paul Gilmartin" To: Sent: Thursday, October 24, 2013 10:43 AM Subject: Re: signum On 2013-10-23 17:26, robin wrote: In Rexx, this could be written with no (explicit) branches as: m = ( j > k ) - ( j < k ); In PL/I, m = sign(j-k); The objective

Re: signum

2013-10-23 Thread Kurt LeBesco
I've been reading quietly and wondering how the dialog drifted off to rexx and pl1 land. Can we get back on topic? Thanks On Oct 23, 2013 7:43 PM, "Paul Gilmartin" wrote: > On 2013-10-23 17:26, robin wrote: > > > >> In Rexx, this could be written with no (explicit) branches > >> as: > >> > >>

Re: Linear search vs binary

2013-10-23 Thread robin
From: "Paul Gilmartin" Sent: Tuesday, October 22, 2013 1:42 AM On 2013-10-21, at 07:13, John Gilmore wrote: Perhaps also worth noting explicitly is that the linear-search scheme done well is not significantly less complex than the binary-search one. You've earlier advocated the value of com

Re: signum

2013-10-23 Thread Paul Gilmartin
On 2013-10-23 17:33, robin wrote: > > What? Rexx'sm = ( j > k ) - ( j < k ); > > would be exactly the same in PL/I. > > However, you would never write it like that. It's just obfuscation. > > simplest (and trivial-est) in PL/I is m = sign(j-k); > But beware: for extreme values of j and k this m

Re: signum

2013-10-23 Thread Paul Gilmartin
On 2013-10-23 17:26, robin wrote: > >> In Rexx, this could be written with no (explicit) branches >> as: >> >>m = ( j > k ) - ( j < k ); > > In PL/I, >m = sign(j-k); > The objective was to synthesize sign() in a language such as Rexx which, unlike PL/I, lacks it. I have occasionally gotten

Re: signum

2013-10-23 Thread robin
- Original Message - From: "John Gilmore" To: Sent: Thursday, October 24, 2013 8:09 AM Subject: Re: signum Boolean values are bits in PL/I. Writing, say, declare (a,b, d) signed binary fixed(63,0), signum signed binary fixed(7, 0), (bigger, equal, smaller) aligned bit ; permits eit

Re: signum

2013-10-23 Thread robin
From: "Paul Gilmartin" Sent: Thursday, October 24, 2013 2:28 AM What are the representations of boolean values in PL/I? A single bit. True is 1, false is 0. In Rexx, this could be written with no (explicit) branches as: m = ( j > k ) - ( j < k ); In PL/I, m = sign(j-k);

Re: signum

2013-10-23 Thread John Gilmore
Boolean values are bits in PL/I. Writing, say, declare (a,b, d) signed binary fixed(63,0), signum signed binary fixed(7, 0), (bigger, equal, smaller) aligned bit ; permits either d = a - b ; select ; when(d > 0) signum = +1 ; when(d = 0) signum = 0 ; when(d < 0) signum = -1 ; end ; o

Re: signum

2013-10-23 Thread Paul Gilmartin
On 2013-10-23, at 07:35, robin wrote: > From: "John Gilmore" > Sent: Wednesday, October 23, 2013 10:02 PM > > >> Interestingly, when I take your C example, >> >> if ( j < k ) m = -1; >> else if (j > k) m = 1; >> else m = 0; >> return m; >> >> and rewrite it trivially modified in PL/I as >> >> if

Re: signum

2013-10-23 Thread robin
From: "John Gilmore" Sent: Wednesday, October 23, 2013 10:02 PM Interestingly, when I take your C example, if ( j < k ) m = -1; else if (j > k) m = 1; else m = 0; return m; and rewrite it trivially modified in PL/I as if j < k then m = -1; else if j > k then m = 1; else m = 0; ret

Re: Linear search vs binary

2013-10-23 Thread Dougie Lawson
Hi Alan, I found some test data. I found a ready written IMS macro to sort my test data (which was a real bonus). And I got your code sample to run and get the right answer. Thank you - I owe you a virtual beer. To all the other correspondents - thank you - a simple request has generated some

Re: Linear search vs binary

2013-10-23 Thread robin
From: "Dougie Lawson" Sent: Monday, October 21, 2013 10:32 PM If I have a table of 3,500 entries of twelve bytes (I'm doing a compare of eight bytes to find the entry I'm looking for and a check on a half word marker for the end of the table to avoid running off the end) then is it worth the p

Re: signum (was: Linear search vs binary)

2013-10-23 Thread Rob van der Heij
I understand. I don't even need a computer to do that :-) The "return" was just to discourage the optimizer to throw away all the code because I didn't use the result. The thing that kept me awake briefly was whether the optimizer would recognize that the shortcut and code a single compare with tw

Re: signum (was: Linear search vs binary)

2013-10-23 Thread John Gilmore
Rob, Interestingly, when I take your C example, if ( j < k ) m = -1; else if (j > k) m = 1; else m = 0; return m; and rewrite it trivially modified in PL/I as if j < k then m = -1; else if j > k then m = 1; else m = 0; return (m); I cannot reproduce your results. John Gilmor

Re: signum (was: Linear search vs binary)

2013-10-23 Thread robin
From: "Rob van der Heij" Sent: Wednesday, October 23, 2013 8:12 PM Since the machine architectures that came to mind all have this 3-state result after comparison, I expected the compiler to take advantage of it when I write something like if ( j < k ) m = -1; else if (j > k) m = 1; else m

Re: signum (was: Linear search vs binary)

2013-10-23 Thread Rob van der Heij
Since the machine architectures that came to mind all have this 3-state result after comparison, I expected the compiler to take advantage of it when I write something like if ( j < k ) m = -1; else if (j > k) m = 1; else m = 0; return m; A few surprises with gcc, like pretty dumb code wit

Re: signum (was: Linear search vs binary)

2013-10-23 Thread robin
From: "John Gilmore" Sent: Tuesday, October 22, 2013 9:31 AM PL/I was robbed of FIXEDOVERFLOW for binary fixed values. Use SIZE instead. It is still available for PL/I decimal fixed, i.e., packed decimal values. The LE does in fact make a facility available for executing what is in efff