/*
* allOddBits - return 1 if all odd-numbered bits in word set to 1
* where bits are numbered from 0 (least significant) to 31 (most significant)
* Examples allOddBits(0xFFFFFFFD) = 0, allOddBits(0xAAAAAAAA) = 1
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 12
* Rating: 2
*/intallOddBits(intx){intmask=0x55+(0x55<<8);mask=mask+(mask<<16);return!(~(mask|x));}
/*
* floatScale2 - Return bit-level equivalent of expression 2*f for
* floating point argument f.
* Both the argument and result are passed as unsigned int's, but
* they are to be interpreted as the bit-level representation of
* single-precision floating point values.
* When argument is NaN, return argument
* Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while
* Max ops: 30
* Rating: 4
*/unsignedfloatScale2(unsigneduf){unsigneds=uf&0x80000000;unsignedexp=uf&0x7f800000;unsignedf=uf&0x007fffff;if(!exp){returns|(uf<<1);}if(!(exp^0x7f800000)){returnuf;}exp=exp+0x00800000;if(exp==0x7f800000){return0x7f800000|s;}returns|(exp&0x7f800000)|f;}
/*
* floatFloat2Int - Return bit-level equivalent of expression (int) f
* for floating point argument f.
* Argument is passed as unsigned int, but
* it is to be interpreted as the bit-level representation of a
* single-precision floating point value.
* Anything out of range (including NaN and infinity) should return
* 0x80000000u.
* Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while
* Max ops: 30
* Rating: 4
*/intfloatFloat2Int(unsigneduf){unsigneds=uf&0x80000000,e=uf&0x7f800000,f=uf&0x007fffff;intexp=(e>>23)-0x7f;unsignedres=f|0x00800000;if(exp<0)return0;if(exp>=31)return0x80000000;if(exp<23)exp=23-exp;elseexp=exp-23;res=res>>exp;if(s)return-res;elsereturnres;}
/*
* floatPower2 - Return bit-level equivalent of the expression 2.0^x
* (2.0 raised to the power x) for any 32-bit integer x.
*
* The unsigned value that is returned should have the identical bit
* representation as the single-precision floating-point number 2.0^x.
* If the result is too small to be represented as a denorm, return
* 0. If too large, return +INF.
*
* Legal ops: Any integer/unsigned operations incl. ||, &&. Also if, while
* Max ops: 30
* Rating: 4
*/unsignedfloatPower2(intx){intexp=0x7f+x;if(exp<0x00)return0;if(exp>=0xff)return0x7f800000;if(exp==0x00)return1;returnexp<<23;}