Results 1 to 2 of 2
  1. #1
    KarlNorway is offline Member
    Join Date
    Dec 2011
    Posts
    57
    Rep Power
    0

    Default Setting lenght of Integer

    Is it possbile to force a integer to be 2 bytes long?

    Im currently working on a application for testing PCBs with SW. The protocol for communication is made up of hex strings. I need to send hex commands with leading zeros.

    Im currently hard coding the commands as int, should I use string instead? ( I have to da a CRC on them as well)

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,416
    Rep Power
    25

    Default Re: Setting lenght of Integer

    If you want an integer value that uses 2 bytes, use the short datatype.

    If you are working with Strings, there are formatting classes and methods that will insert leading "0"s

    Can you give an example of the input data and the output you want?
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Integer Comparison, Outputting Largest Integer Not Working
    By killingthemonkey in forum New To Java
    Replies: 4
    Last Post: 10-16-2011, 08:59 PM
  2. add integer value on each run
    By aconti in forum New To Java
    Replies: 4
    Last Post: 07-12-2011, 08:47 AM
  3. Big integer
    By penguinSlack in forum New To Java
    Replies: 1
    Last Post: 03-14-2011, 04:08 AM
  4. convert unsigned integer to signed integer in java?
    By diskhub in forum New To Java
    Replies: 6
    Last Post: 05-17-2010, 12:50 AM
  5. int count=ss.lenght(); error
    By javastuden in forum New To Java
    Replies: 3
    Last Post: 12-04-2009, 09:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •