Changes between Version 14 and Version 15 of BitwiseCowan


Ignore:
Timestamp:
09/14/16 08:57:14 (12 months ago)
Author:
cowan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BitwiseCowan

    v14 v15  
    6666* These operations interpret exact integers using two's-complement representation. 
    6767 
    68 * It is not optional for the associative bitwise ops to be n-ary instead of merely binary. They are required to be n-ary. Programmers can ''reliably'' write `bitwise-and` with 3 arguments, for example. 
     68* The associative bitwise ops are required to be n-ary. Programmers can ''reliably'' write `bitwise-and` with 3 arguments, for example. 
    6969 
    7070 * The word `or` is never used by itself, only with modifiers: `xor`, `ior`, `nor`, 
     
    107107 
    108108      * "load" and "deposit" are the wrong verbs (e.g., Common Lisp's `ldb` and `dpb` ops), 
    109         since these guys have nothing to do with the store.   
     109        since they have nothing to do with the store.   
    110110     
    111111      * `boole` has been removed; it is not one with the Way of Scheme.  Boolean functions 
     
    152152=== Other sources === 
    153153 
    154 The following procedures are inspired by SRFI 133:  `bit-swap`, `bit-field-append`, 
     154* The following procedures are inspired by SRFI 133:  `bit-swap`, `bit-field-append`, 
    155155`bitwise-fold`, `bitwise-for-each`, `bitwise-unfold`. 
    156156 
     
    171171  size of the field.  SRFI 33 bit-field operations had leading ''position'' and ''size'' 
    172172  arguments instead.  These 
    173   have been replaced in this SRFI by ''start'' (inclusive) and ''end'' (exclusive) 
     173  have been replaced in this SRFI by trailing ''start'' (inclusive) and ''end'' (exclusive) 
    174174  arguments, the convention used not only in SRFI 60 and R6RS but also in most other 
    175175  subsequence operations in Scheme standards and SRFIs. 
     
    205205the corresponding bitwise operator 
    206206maps that function across a pair of bitstrings in a bit-wise fashion. 
    207  
    208207The core idea of this group of functions is this bitwise "lifting" 
    209208of the set of dyadic boolean functions to bitstring parameters. 
     
    302301     
    303302For non-negative ''i'', this is the number of bits needed to 
    304 represent I in an unsigned binary representation. For all ''i'', 
     303represent ''i'' in an unsigned binary representation. For all ''i'', 
    305304`(+ 1 (integer-length `''i''`))` is the number of bits needed 
    306305to represent ''i'' in a signed twos-complement  
     
    370369 
    371370Determines if any/all of the bits set in bitstring ''test-bits'' are set 
    372 in bitstring 'i''. I.e.,  returns `(not (zero? (bitwise-and `''test-bits i''`)))` 
     371in bitstring ''i''. I.e.,  returns `(not (zero? (bitwise-and `''test-bits i''`)))` 
    373372or `(= `''test-bits''` (bitwise-and ''test-bits i'')))` respectively. 
    374373 
     
    376375 
    377376Return the index of the first (smallest index) 1 bit in bitstring ''i''. 
    378 Return -1 if ''i'' contains no 1 bits (i.e., if I is zero). 
     377Return -1 if ''i'' contains no 1 bits (i.e., if ''i'' is zero). 
    379378 
    380379{{{ 
     
    398397`(bit-field `''i start end''`)` 
    399398 
    400 Returns the designated bit field from ''i'', shifted 
     399Returns the field from ''i'', shifted 
    401400down to the least-significant position in the result. 
    402401 
     
    412411`(bit-field-set `''i start end''`)` 
    413412 
    414 Returns ''i'' with the selected field's bits set to all 0s/1s. 
     413Returns ''i'' with the field's bits set to all 0s/1s. 
    415414 
    416415`(bit-field-replace `''dst src start end''`)` 
    417416 
    418 Returns ''dst'' with the designated bit field replaced 
     417Returns ''dst'' with the field replaced 
    419418by the least-significant ''end-start'' bits in ''src''. 
    420419 
    421420`(bit-field-replace-same `''dst src start end''`)` 
    422421 
    423 Returns ''dst'' with the selected field's bits replaced 
    424 by the corresponding field's bits in ''src''. 
     422Returns ''dst'' with its field replaced 
     423by the corresponding field in ''src''. 
    425424 
    426425`(bit-field-rotate `''i count start end''`)` 
    427426 
    428 Returns ''i'' with the selected field cyclically permuted 
     427Returns ''i'' with the field cyclically permuted 
    429428by ''count'' bits towards high-order. 
    430429 
    431430`(bit-field-reverse `''i start end''`)` 
    432431 
    433 Returns ''i'' with the order of the bits in the selected field reversed. 
     432Returns ''i'' with the order of the bits in the field reversed. 
    434433 
    435434`(bit-field-append `''i start end'' ...`)` 
     
    445444 
    446445Returns a list/vector of ''len'' booleans corresponding to each bit of the non-negative integer ''i''. 
    447 `#t` is returned for each 1; `#f` for 0. The len argument defaults to `(integer-length `''i''`)`. 
     446`#t` is returned for each 1; `#f` for 0. The ''len'' argument defaults to `(integer-length `''i''`)`. 
    448447 
    449448`(list->integer `''list''`)`[[BR]] 
     
    486485(whose initial value is ''seed'') is true, return the 
    487486currently accumulated bits as an integer.  Otherwise, apply ''mapper'' 
    488 to the current state to obtain the next bit of the result.  Then get a new state 
     487to the current state to obtain the next bit of the result by interpreting 
     488a true value as a 1 bit and a false value as a 0 bit.  Then get a new state 
    489489by applying ''successor'' to the current state, and repeat this algorithm. 
    490490 
     
    525525||Test bit field (every)||---||---||`bit-field-every?`||---||---||`bit-field-every?`|| 
    526526||Clear bit field||`mask-field`||`clear-bit-field`||`bit-field-clear`||---||---||`bit-field-clear`|| 
     527||Set bit field||---||---||---||---||---||`bit-field-set`|| 
    527528||Replace bit field||`dpb`||`replace-bit-field`||`bit-field-replace`||`copy-bit-field`||`bitwise-copy-bit-field`||`bit-field-replace`|| 
    528529||Replace corresponding bit field||`deposit-field`||`deposit-field`||`copy-bit-field`||---||---||`bit-field-copy-same`|| 
    529 ||Fill bit field||---||---||---||---||---||`bit-field-fill`|| 
    530530||Rotate bit field||---||---||---||`rotate-bit-field`||`bitwise-rotate-bit-field`||`bit-field-rotate`|| 
    531531||Reverse bit field||---||---||---||`reverse-bit-field`||`bitwise-reverse-bit-field`||`bit-field-reverse`||