equal
deleted
inserted
replaced
1604 " |
1604 " |
1605 ! |
1605 ! |
1606 |
1606 |
1607 bitReversed |
1607 bitReversed |
1608 "swap (i.e. reverse) bits in an integer |
1608 "swap (i.e. reverse) bits in an integer |
1609 i.e. a.b.c.d....x.y.z -> z.y.x...b.a.d.c." |
1609 i.e. a.b.c.d....x.y.z -> z.y.x...b.a.d.c. |
|
1610 Warning: |
|
1611 do not use this without care: it depends on the machine's |
|
1612 word size; i.e. a 64bit machine will return a different result as a 32bit machine. |
|
1613 Better use one of the bitReversedXX methods. |
|
1614 This my vanish or be replaced by something better" |
1610 |
1615 |
1611 %{ /* NOCONTEXT */ |
1616 %{ /* NOCONTEXT */ |
1612 #ifndef __SCHTEAM__ |
1617 #ifndef __SCHTEAM__ |
1613 unsigned INT v = __intVal(self); |
1618 unsigned INT v = __intVal(self); |
1614 |
1619 |
1637 // swap 2-byte long pairs |
1642 // swap 2-byte long pairs |
1638 v = ((v >> 16) & 0x0000FFFF) | ((v & 0x0000FFFF) << 16); |
1643 v = ((v >> 16) & 0x0000FFFF) | ((v & 0x0000FFFF) << 16); |
1639 # endif |
1644 # endif |
1640 |
1645 |
1641 if (v <= _MAX_INT) { |
1646 if (v <= _MAX_INT) { |
1642 RETURN ( __mkSmallInteger(v) ); |
1647 RETURN ( __mkSmallInteger(v) ); |
1643 } |
1648 } |
1644 RETURN (__MKUINT(v)); |
1649 RETURN (__MKUINT(v)); |
1645 #endif /* not __SCHTEAM__ */ |
1650 #endif /* not __SCHTEAM__ */ |
1646 %}. |
1651 %}. |
1647 ^ super bitReversed |
1652 ^ super bitReversed |
1649 " |
1654 " |
1650 2r1001 bitReversed printStringRadix:2 |
1655 2r1001 bitReversed printStringRadix:2 |
1651 2r100111010011 bitReversed printStringRadix:2 |
1656 2r100111010011 bitReversed printStringRadix:2 |
1652 -1 bitReversed printStringRadix:2 |
1657 -1 bitReversed printStringRadix:2 |
1653 " |
1658 " |
|
1659 |
|
1660 "Modified (comment): / 27-03-2019 / 18:28:47 / Claus Gittinger" |
1654 ! |
1661 ! |
1655 |
1662 |
1656 bitReversed16 |
1663 bitReversed16 |
1657 "swap (i.e. reverse) the low 16 bits in an integer |
1664 "swap (i.e. reverse) the low 16 bits in an integer |
1658 the high bits are ignored and clear in the result |
1665 the high bits are ignored and clear in the result |