Intop-Bitorder

Reverses the bits of an integer.  This means for a integer type of 32-bit: bit0 and bit31 are swapped, bit1 and bit30 are swapped ...

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2013 Jörg Seebohn

Files

C-kern/api/math/int/bitorder.h

Header file Intop-Bitorder.

C-kern/math/int/bitorder.c

Implementation file Intop-Bitorder impl.

test

unittest_math_int_bitorder

int unittest_math_int_bitorder(void)

Test function int_t.reversebits_int.

int_t

Summary
bit-operations
reversebits_intReverses the bits of an integer.

bit-operations

reversebits_int

unsigned reversebits_int(unsigned i)

Reverses the bits of an integer.  Every set bit of the value i is shifted to position (bitsof(i)-1-bi) where bi is the bit index of the set bit beginning with 0.  0x80 is reversed to 0x01.  0x4010 is reversed into 0x0802.

inline implementation

Macros

reversebits_int

Reverses the bits of an integer.
Implements Intop-Bitorder.
int unittest_math_int_bitorder(void)
Test function int_t.reversebits_int.
unsigned reversebits_int(unsigned i)
Reverses the bits of an integer.
Close