qbitbits.c
Go to the documentation of this file.
00001 #include "f2c.h"
00002 #ifdef __cplusplus
00003 extern "C" {
00004 #endif
00005 
00006 #ifndef LONGBITS
00007 #define LONGBITS 32
00008 #endif
00009 
00010 #ifndef LONG8BITS
00011 #define LONG8BITS (2*LONGBITS)
00012 #endif
00013 
00014  longint
00015 #ifdef KR_headers
00016 qbit_bits(a, b, len) longint a; integer b, len;
00017 #else
00018 qbit_bits(longint a, integer b, integer len)
00019 #endif
00020 {
00021         /* Assume 2's complement arithmetic */
00022 
00023         ulongint x, y;
00024 
00025         x = (ulongint) a;
00026         y = (ulongint)-1L;
00027         x >>= b;
00028         y <<= len;
00029         return (longint)(x & ~y);
00030         }
00031 
00032  longint
00033 #ifdef KR_headers
00034 qbit_cshift(a, b, len) longint a; integer b, len;
00035 #else
00036 qbit_cshift(longint a, integer b, integer len)
00037 #endif
00038 {
00039         ulongint x, y, z;
00040 
00041         x = (ulongint)a;
00042         if (len <= 0) {
00043                 if (len == 0)
00044                         return 0;
00045                 goto full_len;
00046                 }
00047         if (len >= LONG8BITS) {
00048  full_len:
00049                 if (b >= 0) {
00050                         b %= LONG8BITS;
00051                         return (longint)(x << b | x >> LONG8BITS - b );
00052                         }
00053                 b = -b;
00054                 b %= LONG8BITS;
00055                 return (longint)(x << LONG8BITS - b | x >> b);
00056                 }
00057         y = z = (unsigned long)-1;
00058         y <<= len;
00059         z &= ~y;
00060         y &= x;
00061         x &= z;
00062         if (b >= 0) {
00063                 b %= len;
00064                 return (longint)(y | z & (x << b | x >> len - b));
00065                 }
00066         b = -b;
00067         b %= len;
00068         return (longint)(y | z & (x >> b | x << len - b));
00069         }
00070 #ifdef __cplusplus
00071 }
00072 #endif


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:56