byte sorting

Discussion in 'Java' started by lascar, May 12, 2004.

  1. lascar

    lascar Guest

    I'm trying to write some java code in order to talk to a RFID device.
    The protocol I must follow (ISO don't recall what number) asks for every
    query to end with a CRC.
    This CRC must be expressed in a 'least significant byte first' and,
    within a byte, 'least significant bit first'.
    I can decide the order of my 2 CRC bytes. Shall I also work on bitwise
    operations in order to set all bits properly, or is this something
    implicit within the java architecture?
    Thanks,
    Las
    lascar, May 12, 2004
    #1
    1. Advertising

  2. lascar wrote:

    > I'm trying to write some java code in order to talk to a RFID device.
    > The protocol I must follow (ISO don't recall what number) asks for every
    > query to end with a CRC.
    > This CRC must be expressed in a 'least significant byte first' and,
    > within a byte, 'least significant bit first'.
    > I can decide the order of my 2 CRC bytes. Shall I also work on bitwise
    > operations in order to set all bits properly, or is this something
    > implicit within the java architecture?


    Java integer types are logically big-endian with respect to byte order,
    and logically big-endian with respect to bit order within any byte.
    (How these things are expressed in the underlying hardware is
    irrelevant.) Java I/O and networking API will not perform bit
    reordering for you.


    John Bollinger
    John C. Bollinger, May 12, 2004
    #2
    1. Advertising

  3. lascar

    Roedy Green Guest

    On Wed, 12 May 2004 20:17:58 GMT, lascar <> wrote or
    quoted :

    >I can decide the order of my 2 CRC bytes. Shall I also work on bitwise
    >operations in order to set all bits properly, or is this something
    >implicit within the java architecture?


    Java does all i/o bigendian. If you want it little endian you must
    take special measures.

    See http://mindprod.com/jgloss/endian.html

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, May 13, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas
    Replies:
    1
    Views:
    847
    Jonathan Bromley
    May 4, 2004
  2. Bharat Bhushan

    Appending byte[] to another byte[] array

    Bharat Bhushan, Aug 5, 2003, in forum: Java
    Replies:
    15
    Views:
    40,245
    Roedy Green
    Aug 5, 2003
  3. Jean-Daniel Gamache
    Replies:
    0
    Views:
    422
    Jean-Daniel Gamache
    Jul 14, 2004
  4. Peter
    Replies:
    3
    Views:
    725
    Michael Borgwardt
    Aug 5, 2004
  5. Kirby
    Replies:
    3
    Views:
    641
    Kirby
    Oct 8, 2004
Loading...

Share This Page