The Daily Click ::. Forums ::. Klik Coding Help ::. Unsigned And Signed Bytes...
 

Post Reply  Post Oekaki 
 

Posted By Message

gmatharu



Registered
  28/07/2005
Points
  12
10th June, 2006 at 20:45:34 -

Im working with bytes and hex in MMF at the moment.
MMF can without any trouble...
Converting from Single Unsigned bytes to HEX codes (255 -> FF)
Converting from HEX codes to Single Unsigned Bytes (FF -> 255)

The Binary object reads the bytes in Signed Bytes (-1, -2, etc) which is annoying, MMF is easily capable of converting Signed bytes into Unsigned Bytes

"( ( Byte + 256 ) mod 256 )"

Unfortunatly... I am unable to convert from Unsigned to Signed...
All i want to be able to do is work with bytes 0 to 255 (Unsigned), then convert it back to Signed and put it back into the Binary Object...
Can Anyone help me acomplish the opposite conversion ????

Thanks in advance.

Image Edited by the Author.

 
n/a

Tigerworks

Klik Legend

Registered
  15/01/2002
Points
  3882
11th June, 2006 at 01:06:28 -

unsigned - 128 = signed

eg. 0 -> -128
255 -> 127

 
- Tigerworks

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
11th June, 2006 at 01:36:57 -

I had a dream about you last night Tigerworks.

 
n/a

Peblo

Custom ratings must be 50 characters or less

Registered
  05/07/2002
Points
  185

Game of the Week WinnerVIP MemberI'm on a Boat360 OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimePS3 OwnerIt's-a me, Mario!
I'm a Storm TrooperSonic SpeedStrawberryI like Aliens!Wii OwnerMushroomGhostbuster!
11th June, 2006 at 05:20:16 -

You joined #K&P and left before I could talk to you.

 
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath

gmatharu



Registered
  28/07/2005
Points
  12
11th June, 2006 at 13:07:23 -

unsigned - 128 = signed

eg. 0 -> -128
255 -> 127

-----------------------------------------

255 Unsigned is not 127 Signed
255 is supposed to be -1

But i actually did think for a minute Unsigned - 128 would have worked...

eg.
-50 -> 206 (when signed)
206 - 128 = 78 ??

Thanks though Tigerworks, any other ideas ??? anyone else ??? please ??? this has put me to a stop in my work...
Thanks in advance.

-----------------------------------------

Oh my god... okays.. if anyone needs help with this in the future.. i place the solution here.

I was using Microsoft Excel to test the calculations first, because it updates in realtime, then i could put it into MMF if sucessful, finally accidently done this... (I don't know if there is a simplier method but... YAY Finally ! (btw, thanks for help Tigerworks, i started putting random -128 here and there to experiment with... thas how i finally came to it working)

Unsigned -> Signed
( ( byte + 256 ) mod 256 )

Signed -> Unsigned
( ( ( byte + 128 ) mod 256 ) - 128 )

Image Edited by the Author.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click