Find first and last set bit of a long integer: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: added/changed whitespace and comments. optimized some functions, simplified the code.)
m (→‎{{header|REXX}}: corrected a typo, added wording to the REXX section header,)
Line 1,314: Line 1,314:
<br>size ···, but for REXX, the "natural" size is a character string (indeed, the only thing REXX knows are character strings, numbers
<br>size ···, but for REXX, the "natural" size is a character string (indeed, the only thing REXX knows are character strings, numbers
<br>are expressed as character strings), so the output (below) was limited to four times the default size, but the actual limit may be
<br>are expressed as character strings), so the output (below) was limited to four times the default size, but the actual limit may be
<br>around eight million bytes (for some REXXes). &nbsp; REXX programmers have no need to know what the host's word size is.
<br>around eight million bytes (for some REXXes). &nbsp; REXX programmers have no need to know what the host's word size is, &nbsp; as
<br>it is irrelevant.
<lang rexx>/*REXX program finds the first and last set bit of "integer" and "long interger". */
<lang rexx>/*REXX program finds the first and last set bit of "integer" and "long integer". */
@= '─'; @4= copies(@, 4) /*build parts of the separator line. */
@= '─'; @4= copies(@, 4) /*build parts of the separator line. */
!= '│' /* " part " " output " */
!= '│' /* " part " " output " */
Line 1,339: Line 1,340:
rupb: arg #; call n2b #; if #==0 then return -1; return L - 1
rupb: arg #; call n2b #; if #==0 then return -1; return L - 1
sep: arg _; say @d || _ || @4 || _ || @4 || _ || copies(@,length(n2b(10**(d-1)))); return</lang>
sep: arg _; say @d || _ || @4 || _ || @4 || _ || copies(@,length(n2b(10**(d-1)))); return</lang>
{{out|output|text=&nbsp; when using the internal default inputs:}}
{{out}}
<pre>
<pre>
──────────┬──────┬──────┬────────────────────────────
──────────┬──────┬──────┬────────────────────────────