• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting

 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have an array of bytes like

i want a long value how can i convert that
i used
its giving Wrong answer
please help me
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on how exactly the values need to be converted to a long. I suppose the idea in the code that you show is correct: the first value in the array is the most significant byte, and the last value is the least significant byte.

You have to make sure that the shift operations are being done on long values; right now, they are done on int values. You could make the 0xFF a long literal by appending "L", for example:

[ May 11, 2008: Message edited by: Jesper Young ]
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you

and That data is a Double Word data (64bit)
i want to convert that hex value to integer base 10
can you help me
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pavithra Papi:
i want to convert that hex value to integer base 10

What do you mean? 0xFFL in decimal is 255L.
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My problem is i have a register 0f size 32bit
and it giveing 8 digit HEX value
and i want to convert that HEX to Integer base 10 and also i have to take care of -ve values also;
[ May 12, 2008: Message edited by: Pavithra Papi ]
 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI i solved that like
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic