Doxygen Source Code Documentation
lbitbits.c File Reference
#include "f2c.h"
Go to the source code of this file.
Defines | |
#define | LONGBITS 32 |
Functions | |
integer | lbit_bits (integer a, integer b, integer len) |
integer | lbit_cshift (integer a, integer b, integer len) |
Define Documentation
|
Definition at line 4 of file lbitbits.c. Referenced by lbit_cshift(). |
Function Documentation
|
Definition at line 11 of file lbitbits.c.
|
|
Definition at line 29 of file lbitbits.c.
00031 { 00032 unsigned long x, y, z; 00033 00034 x = (unsigned long)a; 00035 if (len <= 0) { 00036 if (len == 0) 00037 return 0; 00038 goto full_len; 00039 } 00040 if (len >= LONGBITS) { 00041 full_len: 00042 if (b >= 0) { 00043 b %= LONGBITS; 00044 return (integer)(x << b | x >> LONGBITS -b ); 00045 } 00046 b = -b; 00047 b %= LONGBITS; 00048 return (integer)(x << LONGBITS - b | x >> b); 00049 } 00050 y = z = (unsigned long)-1; 00051 y <<= len; 00052 z &= ~y; 00053 y &= x; 00054 x &= z; 00055 if (b >= 0) { 00056 b %= len; 00057 return (integer)(y | z & (x << b | x >> len - b)); 00058 } 00059 b = -b; 00060 b %= len; 00061 return (integer)(y | z & (x >> b | x << len - b)); 00062 } |