[Re: [Re: [[basicstamps] Strange serial problems]]]
Archiver
Posts: 46,084
0x is used in C programs to indicate that a number is in hex (hexadecimal, or
base 16). It's like using '$' in a PBasic program.
It's just a notation. It's confusing to people since I switch between
Assembly, C, and PBasic formats in the same sentence sometimes. [noparse]:p[/noparse]
10h = 0x10 = $10 = %10000 = 10000b = 16d
Without the 0x, AA could be a variable name. It helps a compiler figure out
the context, or without assuming things from the context.
smartdim@a... wrote:
> In a message dated 3/15/2003 5:40:21 PM Pacific Standard Time, fkerr@u...
> writes:
>
> > 0xAA and 0x55 are just fun values. In binary they are
> >
> > 10101010 and 01010101
> >
> > Nothing really fancy. Just alternating ones and zeros.
> >
> > Perhaps 0xCC and 0x33 would also be useful.
> >
> > 11001100 and 00110011
>
> So the "0x" has not meaning?
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
base 16). It's like using '$' in a PBasic program.
It's just a notation. It's confusing to people since I switch between
Assembly, C, and PBasic formats in the same sentence sometimes. [noparse]:p[/noparse]
10h = 0x10 = $10 = %10000 = 10000b = 16d
Without the 0x, AA could be a variable name. It helps a compiler figure out
the context, or without assuming things from the context.
smartdim@a... wrote:
> In a message dated 3/15/2003 5:40:21 PM Pacific Standard Time, fkerr@u...
> writes:
>
> > 0xAA and 0x55 are just fun values. In binary they are
> >
> > 10101010 and 01010101
> >
> > Nothing really fancy. Just alternating ones and zeros.
> >
> > Perhaps 0xCC and 0x33 would also be useful.
> >
> > 11001100 and 00110011
>
> So the "0x" has not meaning?
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
Comments
Could use "Debug bin ? Temp" to display "Temp=01010101" but that's not what I
was trying to do in my example.
The "Debug bin(temp),cr" syntax comes from thinking in C syntax. [noparse]:)[/noparse]
Sometimes extra parenthesis makes things clearer, especially if there's a
chance you might make an expression later.
Debug bin(temp+temp1),cr
Rodent <daweasel@s...> wrote:
> Yeah, I learned something new today while writing some robot code -- had a
> brief brain-fart trying to break a decimal value greater than 255 into a
> high and low byte in hex. Pulled my hair out until I saw what I had done
> wrong.
>
> Actually, you would just say:
>
> DEBUG "Temp = %",BIN TEMP,CR
>
> This would display the TEMP variable in binary format and move the cursor
to
> the next line.
>
>
Original Message
>
> > Sorry, I guess I missed that part of the question.
> >
> > You can display values using Debug in the 3 formats:
> >
> > Temp var byte
> > Temp1 var byte
> > Temp = $55
> > Temp1 = %10101010
> > Debug "Temp= %", bin(Temp)," $",hex(Temp), " ", dec(Temp), cr
> > Debug "Temp1= %", bin(Temp1)," $",hex(Temp1), " ", dec(Temp1), cr
> > end
> >
> > (Heh actually I haven't used DEC(), I'm just guessing.)
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>