home *** CD-ROM | disk | FTP | other *** search
/ Beginning Mac Programming / Beginning Mac Programming.bin / pc / Open Me for REALbasic 3 / REALbasic 3.2 / Example Projects / Techniques / Examples by Thomas Tempelmann / BitwiseTools next >
Unknown  |  1999-07-06  |  1.1 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text


This file was not able to be converted.
This format is not currently supported by dexvert.

ConfidenceProgramDetectionMatch TypeSupport
100% file data default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 06 4d 6f 64 75 6c 65 0c | 42 69 74 77 69 73 65 54 |.Module.|BitwiseT|
|00000010| 6f 6f 6c 73 8e 02 a0 04 | 97 0d a4 0a 07 00 0c 42 |ools....|.......B|
|00000020| 69 74 77 69 73 65 54 6f | 6f 6c 73 15 00 00 02 15 |itwiseTo|ols.....|
|00000030| 70 77 72 4f 66 32 28 33 | 31 29 20 61 73 20 49 6e |pwrOf2(3|1) as In|
|00000040| 74 65 67 65 72 01 14 70 | 77 72 49 6e 69 74 65 64 |teger..p|wrInited|
|00000050| 20 61 73 20 42 6f 6f 6c | 65 61 6e 01 04 06 53 65 | as Bool|ean...Se|
|00000060| 74 42 69 74 36 76 61 6c | 75 65 20 61 73 20 49 6e |tBit6val|ue as In|
|00000070| 74 65 67 65 72 2c 20 62 | 69 74 4e 75 6d 62 65 72 |teger, b|itNumber|
|00000080| 20 61 73 20 49 6e 74 65 | 67 65 72 2c 20 74 6f 31 | as Inte|ger, to1|
|00000090| 20 61 73 20 42 6f 6f 6c | 65 61 6e 07 49 6e 74 65 | as Bool|ean.Inte|
|000000a0| 67 65 72 00 03 0e 03 0e | 0c 92 01 46 75 6e 63 74 |ger.....|...Funct|
|000000b0| 69 6f 6e 20 53 65 74 42 | 69 74 28 76 61 6c 75 65 |ion SetB|it(value|
|000000c0| 20 61 73 20 49 6e 74 65 | 67 65 72 2c 20 62 69 74 | as Inte|ger, bit|
|000000d0| 4e 75 6d 62 65 72 20 61 | 73 20 49 6e 74 65 67 65 |Number a|s Intege|
|000000e0| 72 2c 20 74 6f 31 20 61 | 73 20 42 6f 6f 6c 65 61 |r, to1 a|s Boolea|
|000000f0| 6e 29 20 41 73 20 49 6e | 74 65 67 65 72 33 2f 2f |n) As In|teger3//|
|00000100| 20 73 65 74 73 20 6f 72 | 20 63 6c 65 61 72 73 20 | sets or| clears |
|00000110| 61 20 62 69 74 20 69 6e | 20 74 68 65 20 33 32 20 |a bit in| the 32 |
|00000120| 42 69 74 20 69 6e 74 65 | 67 65 72 20 76 61 6c 75 |Bit inte|ger valu|
|00000130| 65 10 44 69 6d 20 78 20 | 61 73 20 49 6e 74 65 67 |e.Dim x |as Integ|
|00000140| 65 72 19 78 20 3d 20 56 | 61 6c 75 65 4f 66 42 69 |er.x = V|alueOfBi|
|00000150| 74 28 62 69 74 4e 75 6d | 62 65 72 29 0b 69 66 20 |t(bitNum|ber).if |
|00000160| 74 6f 31 20 74 68 65 6e | 06 2f 2f 20 73 65 74 1b |to1 then|.// set.|
|00000170| 72 65 74 75 72 6e 20 42 | 69 74 77 69 73 65 4f 72 |return B|itwiseOr|
|00000180| 20 28 76 61 6c 75 65 2c | 20 78 29 04 65 6c 73 65 | (value,| x).else|
|00000190| 08 2f 2f 20 63 6c 65 61 | 72 29 72 65 74 75 72 6e |.// clea|r)return|
|000001a0| 20 42 69 74 77 69 73 65 | 41 6e 64 20 28 76 61 6c | Bitwise|And (val|
|000001b0| 75 65 2c 20 42 69 74 77 | 69 73 65 4e 6f 74 20 28 |ue, Bitw|iseNot (|
|000001c0| 78 29 29 03 65 6e 64 0c | 45 6e 64 20 46 75 6e 63 |x)).end.|End Func|
|000001d0| 74 69 6f 6e 08 49 73 42 | 69 74 53 65 74 26 76 61 |tion.IsB|itSet&va|
|000001e0| 6c 75 65 20 61 73 20 49 | 6e 74 65 67 65 72 2c 20 |lue as I|nteger, |
|000001f0| 62 69 74 4e 75 6d 62 65 | 72 20 61 73 20 49 6e 74 |bitNumbe|r as Int|
|00000200| 65 67 65 72 07 42 6f 6f | 6c 65 61 6e 00 01 24 01 |eger.Boo|lean..$.|
|00000210| 24 03 84 01 46 75 6e 63 | 74 69 6f 6e 20 49 73 42 |$...Func|tion IsB|
|00000220| 69 74 53 65 74 28 76 61 | 6c 75 65 20 61 73 20 49 |itSet(va|lue as I|
|00000230| 6e 74 65 67 65 72 2c 20 | 62 69 74 4e 75 6d 62 65 |nteger, |bitNumbe|
|00000240| 72 20 61 73 20 49 6e 74 | 65 67 65 72 29 20 41 73 |r as Int|eger) As|
|00000250| 20 42 6f 6f 6c 65 61 6e | 35 72 65 74 75 72 6e 20 | Boolean|5return |
|00000260| 42 69 74 77 69 73 65 41 | 6e 64 20 28 76 61 6c 75 |BitwiseA|nd (valu|
|00000270| 65 2c 20 56 61 6c 75 65 | 4f 66 42 69 74 28 62 69 |e, Value|OfBit(bi|
|00000280| 74 4e 75 6d 62 65 72 29 | 29 20 3c 3e 20 30 0c 45 |tNumber)|) <> 0.E|
|00000290| 6e 64 20 46 75 6e 63 74 | 69 6f 6e 0a 56 61 6c 75 |nd Funct|ion.Valu|
|000002a0| 65 4f 66 42 69 74 10 62 | 69 74 4e 6f 20 61 73 20 |eOfBit.b|itNo as |
|000002b0| 49 6e 74 65 67 65 72 07 | 49 6e 74 65 67 65 72 00 |Integer.|Integer.|
|000002c0| 0f 13 0f 13 12 30 46 75 | 6e 63 74 69 6f 6e 20 56 |.....0Fu|nction V|
|000002d0| 61 6c 75 65 4f 66 42 69 | 74 28 62 69 74 4e 6f 20 |alueOfBi|t(bitNo |
|000002e0| 61 73 20 49 6e 74 65 67 | 65 72 29 20 41 73 20 49 |as Integ|er) As I|
|000002f0| 6e 74 65 67 65 72 12 2f | 2f 20 72 65 74 75 72 6e |nteger./|/ return|
|00000300| 73 20 32 5e 62 69 74 4e | 6f 13 44 69 6d 20 69 2c |s 2^bitN|o.Dim i,|
|00000310| 20 78 20 61 73 20 49 6e | 74 65 67 65 72 15 69 66 | x as In|teger.if|
|00000320| 20 6e 6f 74 20 70 77 72 | 49 6e 69 74 65 64 20 74 | not pwr|Inited t|
|00000330| 68 65 6e 05 78 20 3d 20 | 31 0f 66 6f 72 20 69 20 |hen.x = |1.for i |
|00000340| 3d 20 30 20 74 6f 20 33 | 30 0d 70 77 72 4f 66 32 |= 0 to 3|0.pwrOf2|
|00000350| 28 69 29 20 3d 20 78 09 | 78 20 3d 20 32 20 2a 20 |(i) = x.|x = 2 * |
|00000360| 78 04 6e 65 78 74 17 70 | 77 72 4f 66 32 28 33 31 |x.next.p|wrOf2(31|
|00000370| 29 20 3d 20 26 48 38 30 | 30 30 30 30 30 30 10 70 |) = &H80|000000.p|
|00000380| 77 72 49 6e 69 74 65 64 | 20 3d 20 74 72 75 65 03 |wrInited| = true.|
|00000390| 65 6e 64 1f 69 66 20 62 | 69 74 4e 6f 20 3c 20 30 |end.if b|itNo < 0|
|000003a0| 20 6f 72 20 62 69 74 4e | 6f 20 3e 20 33 31 20 74 | or bitN|o > 31 t|
|000003b0| 68 65 6e 1e 52 61 69 73 | 65 20 6e 65 77 20 4f 75 |hen.Rais|e new Ou|
|000003c0| 74 4f 66 42 6f 75 6e 64 | 73 45 78 63 65 70 74 69 |tOfBound|sExcepti|
|000003d0| 6f 6e 04 65 6c 73 65 14 | 72 65 74 75 72 6e 20 70 |on.else.|return p|
|000003e0| 77 72 4f 66 32 28 62 69 | 74 4e 6f 29 03 65 6e 64 |wrOf2(bi|tNo).end|
|000003f0| 0c 45 6e 64 20 46 75 6e | 63 74 69 6f 6e 0a 42 69 |.End Fun|ction.Bi|
|00000400| 74 77 69 73 65 4e 6f 74 | 0c 76 20 61 73 20 49 6e |twiseNot|.v as In|
|00000410| 74 65 67 65 72 07 49 6e | 74 65 67 65 72 00 02 0d |teger.In|teger...|
|00000420| 02 0d 04 2c 46 75 6e 63 | 74 69 6f 6e 20 42 69 74 |...,Func|tion Bit|
|00000430| 77 69 73 65 4e 6f 74 28 | 76 20 61 73 20 49 6e 74 |wiseNot(|v as Int|
|00000440| 65 67 65 72 29 20 41 73 | 20 49 6e 74 65 67 65 72 |eger) As| Integer|
|00000450| 1c 2f 2f 20 72 65 74 75 | 72 6e 73 20 61 6c 6c 20 |.// retu|rns all |
|00000460| 62 69 74 73 20 69 6e 76 | 65 72 74 65 64 0d 72 65 |bits inv|erted.re|
|00000470| 74 75 72 6e 20 2d 31 20 | 2d 20 76 0c 45 6e 64 20 |turn -1 |- v.End |
|00000480| 46 75 6e 63 74 69 6f 6e | 00 00 00 00 00 |Function|..... |
+--------+-------------------------+-------------------------+--------+--------+