Changeset 38930 in project
 Timestamp:
 08/30/20 06:22:01 (4 weeks ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

wiki/eggref/5/bitwiseutils
r38589 r38930 9 9 10 10 Additional bitwise routines. 11 12 === logicalshiftleft 13 14 <procedure>(logicalshiftleft N1 N2) > integer</procedure> 15 16 Returns left shift of {{N1}} by {{N2}} bits. 17 18 ; {{N1}} : {{integer}} ; what to shift. 19 ; {{N2}} : {{fixnum}} ; amount to shift. 20 21 Aliases {{arithmeticshift}}. 22 23 === logicalshiftright 24 25 <procedure>(logicalshiftright N1 N2) > integer</procedure> 26 27 Returns right shift of {{N1}} by {{N2}} bits. Sign preserving. 28 29 ; {{N1}} : {{integer}} ; what to shift. 30 ; {{N2}} : {{fixnum}} ; amount to shift. 31 32 === arithmeticshiftleft 33 34 <procedure>(arithmeticshiftleft N1 N2) > integer</procedure> 35 36 Returns left shift of {{N1}} by {{N2}} bits. 37 38 ; {{N1}} : {{integer}} ; what to shift. 39 ; {{N2}} : {{fixnum}} ; amount to shift. 40 41 Aliases {{arithmeticshift}}. 42 43 === arithmeticshiftright 44 45 <procedure>(arithmeticshiftright N1 N2) > integer</procedure> 46 47 Returns right shift of {{N1}} by {{N2}} bits. Sign extending. 48 49 ; {{N1}} : {{integer}} ; what to shift. 50 ; {{N2}} : {{fixnum}} ; amount to shift. 51 52 Essentially {{(arithmeticshift <> ( <>))}}. 11 53 12 54 === bitwisemask … … 59 101 ; {{N}} : {{integer}} 60 102 61 === logicalshiftleft 62 63 <procedure>(logicalshiftleft N1 N2) > integer</procedure> 64 65 Returns left shift of {{N1}} by {{N2}} bits. 66 67 ; {{N1}} : {{integer}} ; what to shift. 68 ; {{N2}} : {{fixnum}} ; amount to shift. 69 70 Aliases {{arithmeticshift}}. 71 72 === logicalshiftright 73 74 <procedure>(logicalshiftright N1 N2) > integer</procedure> 75 76 Returns right shift of {{N1}} by {{N2}} bits. Sign preserving. 77 78 ; {{N1}} : {{integer}} ; what to shift. 79 ; {{N2}} : {{fixnum}} ; amount to shift. 80 81 === arithmeticshiftleft 82 83 <procedure>(arithmeticshiftleft N1 N2) > integer</procedure> 84 85 Returns left shift of {{N1}} by {{N2}} bits. 86 87 ; {{N1}} : {{integer}} ; what to shift. 88 ; {{N2}} : {{fixnum}} ; amount to shift. 89 90 Aliases {{arithmeticshift}}. 91 92 === arithmeticshiftright 93 94 <procedure>(arithmeticshiftright N1 N2) > integer</procedure> 95 96 Returns right shift of {{N1}} by {{N2}} bits. Sign extending. 97 98 ; {{N1}} : {{integer}} ; what to shift. 99 ; {{N2}} : {{fixnum}} ; amount to shift. 100 101 Essentially {{(arithmeticshift <> ( <>))}}. 103 === bitwisemerge 104 105 <procedure>(bitwisemerge MASK N0 N1) > integer</procedure> 106 107 ; {{MASK}} : {{integer}} 108 ; {{N0}} : {{integer}} 109 ; {{N1}} : {{integer}} 110 111 {{SRFI60}} {{bitwiseif}} 112 113 === bitwisenth? 114 115 <procedure>(bitwisenth? INDEX N) > boolean</procedure> 116 117 ; {{INDEX}} : {{integer}} 118 ; {{N}} : {{fixnum}} 119 120 {{SRFI60}} {{bitset?}} 121 122 === bitwiseany? 123 124 <procedure>(bitwiseany? N1 N2) > boolean</procedure> 125 126 ; {{N1}} : {{integer}} 127 ; {{N2}} : {{integer}} 128 129 {{SRFI60}} {{anybitsset?}} 130 131 === bitwisefirstset 132 133 <procedure>(bitwisefirstset N) > fixnum</procedure> 134 135 ; {{N}} :integer 136 137 {{SRFI60}} {{firstsetbit}} 138 139 === bitwisereverse 140 141 <procedure>(bitwisereverse N K) > integer</procedure> 142 143 ; {{N}} :integer 144 ; {{K}} :fixnum 145 146 === bitwiserotate 147 148 <procedure>(bitwiserotate TO INDEX LEN) > integer</procedure> 149 150 ; {{TO}} : {{integer}} 151 ; {{INDEX}} : {{fixnum}} 152 ; {{LEN}} : {{fixnum}} 153 154 === bitwisesetnth 155 156 <procedure>(bitwisesetnth TO INDEX ON?) > integer</procedure> 157 158 ; {{TO}} : {{integer}} 159 ; {{INDEX}} : {{fixnum}} 160 ; {{ON?}} : {{boolean}} ; {{#t}} is {{#b1}}, {{#f}} is {{#b0}} 161 162 {{SRFI60}} {{(copybit k n b)}}; note argument order change 163 164 === bitwisefield 165 166 <procedure>(bitwisefield N START END) > integer</procedure> 167 168 ; {{N}} : {{integer}} 169 ; {{START}} : {{fixnum}} 170 ; {{END}} : {{fixnum}} 171 172 {{SRFI60}} {{bitfield}} 173 174 === bitwisefieldcopy 175 176 <procedure>(bitwisefieldcopy TO FROM START END) > integer</procedure> 177 178 ; {{TO}} : {{integer}} 179 ; {{FROM}} : integer 180 ; {{START}} : {{fixnum}} 181 ; {{END}} : {{fixnum}} 182 183 {{SRFI60}} {{copybitfield}} 184 185 === bitwisefieldreverse 186 187 <procedure>(bitwisefieldreverse N START END) > integer</procedure> 188 189 ; {{N}} : {{integer}} 190 ; {{START}} : {{fixnum}} 191 ; {{END}} : {{fixnum}} 192 193 {{SRFI60}} {{reversebitfield}} 194 195 <procedure>(bitwisefieldrotate N COUNT START END) > integer</procedure> 196 197 ; {{N}} : {{integer}} 198 ; {{COUNT}} : {{fixnum}} 199 ; {{START}} : {{fixnum}} 200 ; {{END}} : {{fixnum}} 201 202 {{SRFI60}} {{rotatebitfield}} 203 204 === integer>list 205 206 <procedure>(integer>list K [LEN]) > (listof fixnum)</procedure> 207 208 ; {{K}} : {{integer}} 209 ; {{LEN}} : {{(or false fixnum)}} ; {{#f}} is all bits, otherwise number of bits 210 211 === list>integer 212 213 <procedure>(list>integer BOOLS) > integer</procedure> 214 215 ; {{BOOLS}} : {{list}} ; treated as {{(listof booleanlike)}} 102 216 103 217 … … 116 230 == Version history 117 231 232 ; 1.1.4: Fix {{integer>list}} type. 233 ; 1.1.3 : . 234 ; 1.1.2 : . 235 ; 1.1.1 : . 236 ; 1.1.0 : Add {{srfi60}} module. 237 ; 1.0.1 : . 118 238 ; 1.0.0 : Release. 119 239
Note: See TracChangeset
for help on using the changeset viewer.