Results 1 to 5 of 5
Thread: negative ASCII to hex
- 12-13-2011, 11:53 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 2
- Rep Power
- 0
negative ASCII to hex
I am reading a file (Its DICOM binary file..let it be)...i get ASCII value 32...it can be easily converted to its hex value 20 using numerous java programes that convert "ASCII to hex"... but sometimes i get following values in input file
-32
-116
the problem is how to convert these type of(-ve) ASCII to hex...hex Value of dec -32 is 00 20 but the normal ascii to hex shows it 0x0E which is wrong...help
- 12-13-2011, 12:25 PM #2
Banned
- Join Date
- Dec 2011
- Posts
- 143
- Rep Power
- 0
Re: negative ASCII to hex
First question is, "Is your file really ASCII?" If you are reading negative byte data values, I suspect it is not.
It may be using an ANSI code page or UNICODE. If it is, it will contain values greater than 127 which will show up as negative if represented as a byte data type.
-32 for example is 11100000 in binary which is 0xE0
This is a valid ANSI or UNICODE code unit. It is not a valid ASCII code point.Last edited by 2by4; 12-13-2011 at 12:36 PM.
- 12-13-2011, 03:49 PM #3
Member
- Join Date
- Dec 2011
- Posts
- 2
- Rep Power
- 0
Re: negative ASCII to hex
ok then how to deal with it...means how to get 00 20 from -32?thnx for reply
- 12-13-2011, 04:12 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 26
Re: negative ASCII to hex
How are you actually doing this conversion?
Should be simple to show us a demo using just a "byte b = -32" and converting that.
At the moment I can't see what it is you;re actually doing.
- 12-13-2011, 04:57 PM #5
Similar Threads
-
help - Ascii to hex and hex to ascii conversion
By rjagan in forum New To JavaReplies: 8Last Post: 06-14-2011, 01:53 PM -
Negative,Positive and Zero
By dipowo in forum New To JavaReplies: 2Last Post: 04-04-2011, 06:49 AM -
Mod of Negative Numbers
By Venny in forum New To JavaReplies: 7Last Post: 01-28-2011, 06:32 AM -
Help with negative numbers
By cela0811 in forum New To JavaReplies: 2Last Post: 01-04-2011, 06:04 PM -
Byte value comes out negative
By Bluefox815 in forum New To JavaReplies: 1Last Post: 07-03-2010, 04:52 AM
Bookmarks