two's complement 8 bit data to decimal

  • Follow


Hi guys,

does anyone knows how to convert a 8-bit data in the two's complement format back to signed decimal number?

Thanks,

AL
0
Reply Albono 3/10/2010 7:33:09 AM

"Albono Bonomi" <alb.bonomi@gmail.com> wrote in message <hn7hvl$37c$1@fred.mathworks.com>...
> 
> Hi guys,
> 
> does anyone knows how to convert a 8-bit data in the two's complement format back to signed decimal number?
> 
> Thanks,
> 
> AL

Depends on how you currently have it stored. Assuming it is in a double value you can use typecast like this:

d = 255
u8 = uint8(d)
s8 = typecast(u8,'int8')
d = double(s8)

James Tursa
0
Reply James 3/10/2010 8:03:22 AM


It works, problem solved.
Thank you James.


"James Tursa" <aclassyguy_with_a_k_not_a_c@hotmail.com> wrote in message <hn7joa$fin$1@fred.mathworks.com>...
> "Albono Bonomi" <alb.bonomi@gmail.com> wrote in message <hn7hvl$37c$1@fred.mathworks.com>...
> > 
> > Hi guys,
> > 
> > does anyone knows how to convert a 8-bit data in the two's complement format back to signed decimal number?
> > 
> > Thanks,
> > 
> > AL
> 
> Depends on how you currently have it stored. Assuming it is in a double value you can use typecast like this:
> 
> d = 255
> u8 = uint8(d)
> s8 = typecast(u8,'int8')
> d = double(s8)
> 
> James Tursa
0
Reply Albono 3/10/2010 8:22:05 AM

2 Replies
1080 Views

(page loaded in 0.036 seconds)

Similiar Articles:













7/20/2012 11:26:53 AM


Reply: