Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7067243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:10:42+00:00 2026-05-28T05:10:42+00:00

I am trying to mimick a old legacy C program behavior in Java. The

  • 0

I am trying to mimick a old legacy C program behavior in Java. The C code is :

void calc_crc(unsigned char *datbuff,unsigned int length)
{
static unsigned char tmp;
static unsigned int crc,zaehler;
crc = 0;
for (zaehler = 0;zaehler < length ;zaehler ++)
{
tmp=(unsigned char) (crc>>8) ;
crc=(crc<<8) ^ crctab[tmp] ^ *datbuff;
datbuff++;
}
}

static unsigned short crctab[256] =
{ // Some values
};

The first issue is this code uses unsigned where as java is signed. Trying hard to retain those values.
Can we get the same results in java too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:10:42+00:00Added an answer on May 28, 2026 at 5:10 am

    The easiest way is to always use at least one size up. i.e. where C uses a char, you use a short or an int. In this case it will require more fiddling with the values to keep them in check, but that can be handled with masking for the most part.

    The longer answer is that you can do the same operations on signed variables, but translate all the values. Also, be very careful with your shifts in java, make sure to use >>> or you’ll just confuse yourself. >> is a signed right shift, >>> is unsigned. For the most part, your code may just work if you make sure to use the correct size variables and the correct shift operators.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to mimic the following Java code: int[][] multi; // DIMENSIONS ARE UNKNOWN
I have been trying to develop a Java ME application using WTK 2.5.2 (Java
Stick with me on this one. I'm trying to mimick CSS3 transitions and (as
I am trying to mimic the following PHP code in C# <?php if (
I am trying to mimic the behavior of, for example, Windows Explorer and how
For (auto-)educational purposes, I'm trying to mimic the super behavior to learn how it
I am trying to mimick the left outer join here but using dynamic linq
I'm trying to mimic the login page from the example http://tipfy-auth.appspot.com (source http://code.google.com/p/tipfy/source/browse/examples/auth/app/ )
I have javascript code that i am trying to mimic in an android application:
I am trying to mimic template behavior in C++ using macros. For instance, if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.