[Tutor] stumped again adding bytes

shawn bright nephish at gmail.com
Wed Feb 21 21:25:02 CET 2007


oh, sorry, i meant how to get the 0x0A27 out of two bytes
a = 0x27 and b = 0x8A

actually, in my script, i am not using the hex values at all, i have
these because they are examples in the documentation of a machine i am
talking to. i am actually using ord(a) and ord(b) to get digital
values of the numbers

so, i guess a better question is how to get 2599 from the ord(a) and
ord(b), how do i put the two bytes together to make one number?

thanks for your help


On 2/21/07, Luke Paireepinart <rabidpoobear at gmail.com> wrote:
> shawn bright wrote:
> > Hey all, thanks for the help yesterday on finding out if an msb is set or not.
> >
> > i am now kinda stumped with discovering the value of two bytes together.
> >
> > ok, if i have two bytes that together make a number, how do i find that number?
> > i know that i do not add them.
> >
> > like byte_a = 39
> > byte_b = 138
> >
> > together, they make 2599
> >
> > in hex they look like this
> > byte_a = 0x27
> > byte_b = 0x8A
> >
> > together = 0x0A27
> >
> > i am making the integers with ord(a) and ord(b)
> >
> > how do i put them together ?
> >
>  >>> int("0x0A27",16)
> 2599
>
> Hope that helps :)
> -Luke
> > thanks
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
>
>


More information about the Tutor mailing list