Re: need an unsigned int in java, so...
- From: googmeister@xxxxxxxxx
- Date: 28 Jul 2005 07:23:15 -0700
J. David Boyd wrote:
> what's the workaround?
>
> I've got some legacy C code that I need to convert to java, and some of it
> depends on unsigned ints.
>
> The code is doing some kind of stupid crc and xor to encrypt the password
> entered by a user.
>
> When I convert it to java, and run it, sometimes the summation variables go
> negative, changing some of the values in my encrypted string.
>
> Any pointers, ideas, or URLs as to what to do to get around this?
I think you should be able to get this to work with regular signed
integers.
What part fails with signed integers? Bitwise and, xor, and + work the
same for signed and unsigned int (i.e., you get the same bits), so it
shouldn't
matter that Java only has signed. On the other hand right shifting is
different - be sure to use >>> instead of >>. (The remainder and
comparison operators are also different for signed and unsigned types,
but you shouldn't need this in CRC code.)
.
- Follow-Ups:
- Re: need an unsigned int in java, so...
- From: J. David Boyd
- Re: need an unsigned int in java, so...
- References:
- need an unsigned int in java, so...
- From: J. David Boyd
- need an unsigned int in java, so...
- Prev by Date: Re: need an unsigned int in java, so...
- Next by Date: Re: need an unsigned int in java, so...
- Previous by thread: Re: need an unsigned int in java, so...
- Next by thread: Re: need an unsigned int in java, so...
- Index(es):
Relevant Pages
|