From: Albono Bonomi on

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
From: James Tursa on
"Albono Bonomi" <alb.bonomi(a)gmail.com> wrote in message <hn7hvl$37c$1(a)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
From: Albono Bonomi on
It works, problem solved.
Thank you James.


"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hn7joa$fin$1(a)fred.mathworks.com>...
> "Albono Bonomi" <alb.bonomi(a)gmail.com> wrote in message <hn7hvl$37c$1(a)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
 | 
Pages: 1
Prev: Basics
Next: hyperbolic interpolation