Not getting the char value:
#define XL 33
#define OR 113
#define NOR 313
#define TN 344
int to_bits(int critn,char *mask)
{
unsigned int x;
int begin;
if (critn < XL) begin = 1;
else if (critn < OR) begin = XL;
else if (critn < NOR) begin = OR;
else if (critn <= TN) begin = NOR;
else begin = 0;
x = critn - begin;
*mask = (char)(0x80 >> (x % 8));
return (int)(x >> 3); // fast divide by 8
}
For explanations and example of the method please see Explain the following C++ method.
I have written the following method in Java:
ClassA{
final static int xl = 33;
final static int or = 113;
final static int nor = 313;
final static int tn = 344;
public int to_bits(int critn){
int x;
int begin;
if(critn<xl)
begin = 1;
else if (critn<or)
begin = xl;
else if (critn<nor)
begin = or;
else if (critn<tn)
begin = nor;
else begin = 0;
x = critn - begin;
char mask = (char)(0x80 >> (x % 8));
System.out.println(mask);
return (int)(x >> 3);
}
public static void main(String args[]){
ClassA a =new ClassA();
a.to_bits(312);
}
}
Can we take the output of mask into Bitset object. I am getting out put as (a special char output for the char field)
24.
Please suggest also how to get both the character and integer values. thanks