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

Re: signum (was: Linear search vs binary)

2013-10-21 Thread John Gilmore
PL/I was robbed of FIXEDOVERFLOW for binary fixed values. 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 efffect an arbitrary SPM instruction; but it is documented so poorly---It has been all but h

signum (was: Linear search vs binary)

2013-10-21 Thread Paul Gilmartin
On 2013-10-21 11:06, John Gilmore wrote: > > [signum] is available as a BIF called sign in PL/I, where it is [almost > always] > implemented in line. An analogous function is available for strings > in C, where it is implemented as a library subroutine. It has always > been available in FORTRAN