byte problem in JAVA

java India
  • 15 years ago

    byte [] getFraction(int s)
           {
                   byte t[] = new byte[6];
                   // 0 1 2 3 4 5
                   int i,j,k;
                   int m = s;
                   for(i = 0;m > 255;i++)
                           m -= 255;
                   System.out.println("value of s in getFraction = " + m);
                   t[1] = (byte)m;
                   System.out.println("value of t[1]  in getFraction = " + (int)t[1]);
                   System.out.println("value of s in (byte)s = " + (byte)m);
                   if(i > 255)
                   {
                          t[0] = 0;
                          for(j = 0;i > 255;j++)
                                   i -= 255;
                          t[3] = (byte)i;
                          if(j > 255)
                          {
                                   t[2] = 0;
                                   for(k = 0;j > 255;k++)
                                           j -= 255;
                                   t[5] = (byte)j;
                                   t[4] = (byte)k;
                          }
                          else
                                 t[2] = (byte)j;
                                 
                    }
                    else
                       t[0] = (byte)i;
                    return t;
           }


    this code has a problem in line 10 here value of m is less than 255 but still
    t is having a value of -39 plz help me

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The difference between theory and practice is smaller in theory than in practice.”