Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

qbitbits.c

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

Powered by Plone

This site conforms to the following standards: