Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2010-10-11T23:20:00Z by Jimmy.Murphy
SystemAdmin
SystemAdmin
4672 Posts
ACCEPTED ANSWER

Pinned topic Help me Regarding the Packed No Sign issue. Im sending the Sample code

‏2006-03-23T06:31:42Z |
This code is for Unpacking the data which is packed. I need the sample data which is packed. I need the sample code for packing the data. I am new to this domain, plzz help me regarding this issue I'll be greatfull to u.
public class PackedDemo{
public static void main(String arg[]){
String str = "12";
byte[] b = new byte10;
b=str.getBytes();
System.out.println("bytes :"+b);
int res = extractComp3(b);
System.out.println("result :"+res);
}
public static int extractComp3(byte[] comp3) {
// C = positive value, D = negative value
int sign = 1;
int rtn = 0;
int nibbles = 0;
for (int i = comp3.length; i > 0; i--) {
if (i == comp3.length) {
if ((comp3i-1 & 0x0D) == 0x0D) {
sign = -1;
}
rtn = ((comp3i-1>>4) & 0x0F);
nibbles++;
} else {
rtn += (int)((int)(comp3i-1 & 0x0F) * Math.pow(10, nibbles++));
System.out.println("rtn1 :"+rtn);
rtn += (int)((int)((comp3i-1>>4) & 0x0F) * Math.pow(10, nibbles++));
System.out.println("rtn2 :"+rtn);
}

}
rtn *= sign;
//log.debug("extractComp3 Returning: " + String.valueOf(rtn));
return rtn;
}
}
Updated on 2010-10-11T23:20:00Z at 2010-10-11T23:20:00Z by Jimmy.Murphy
  • SystemAdmin
    SystemAdmin
    4672 Posts
    ACCEPTED ANSWER

    Re: Help me Regarding the Packed No Sign issue. Im sending the Sample code

    ‏2006-03-26T03:01:39Z  in response to SystemAdmin
    I don't have a clue what you are asking for here. Ignoring the fact that this has nothing to do with client-side Java (the focus of this forum),

    huh?
  • Jimmy.Murphy
    Jimmy.Murphy
    1 Post
    ACCEPTED ANSWER

    Re: Help me Regarding the Packed No Sign issue. Im sending the Sample code

    ‏2010-10-11T23:20:00Z  in response to SystemAdmin
    jaz wrote:
    I don't have a clue what you are asking for here. Ignoring the fact that this has nothing to do with client-side Java (the focus of this forum),

    huh?

    Thanks very much! Anyone have got the solution?