while we are at it, what exactly is "ord"??

Nick (not a programmer since fortran at eng school and forth on the
amstrad 6128)

by the way this would be simple in forth

decimal 134 hex .    produces
86
assuming a word readser which reads one char from the serial port and
places it on the stack:

readser
dup
decimal . hex .     produces
134 86

On Thu, 28 Aug 2003 13:17:00 +1200
Carey Evans <[EMAIL PROTECTED]> wrote:

> Matthew Gregan <[EMAIL PROTECTED]> writes:
> 
> [snip]
> 
> >>>> print "%d" % ord(z)
> > 247
> >>>> print "%c" % ord(z)
> > �
> >>>> print "%x" % ord(z)
> > f7
> 
> You don't really need to use %-formatting here though:
> 
> >>> print ord(z)
> 247
> >>> print chr(ord(z))
> �
> >>> print hex(ord(z))
> 0xf7
> 
> Which option to use depends on what you intend to do with the results.
> 
> -- 
> "Hanging is too good for a man who makes puns; he should be drawn and quoted."
>         -- Fred Allen
> 

-- 
Nick Rout <[EMAIL PROTECTED]>

Reply via email to