Page 1 of 1

How simple an 8 bit output?

Posted: Tue Aug 17, 2021 9:34 pm
by Jan Volk
wlog
e = &b00000101 ' decimal 5
f = &b10000001 ' decimal 129
wlog bin$(e), bin$(f) ' output: 101 10000001
wlog e, f ' output: 5 129
wlog
wlog str$(e, "%3.0f") ' output: 5
wlog str$(f, "%3.0f") ' output: 129
wlog str$(e, "%08x") ' output: 00000000
end

' How do I get the output for e: 00000101 ?
' Can the binary value also be integrated in the str$( ) function e.g. str$(e, "%08b") ?

Re: How simple an 8 bit output?

Posted: Wed Aug 18, 2021 8:31 am
by cicciocb
You can simply do

Code: [Local Link Removed for Guests]

e = &b00000101 ' decimal 5
wlog right$("00000000" + bin$(e), 8)

Re: How simple an 8 bit output?

Posted: Wed Aug 18, 2021 12:56 pm
by Jan Volk
Thank you Cicciocb for your quick response

I didn't know Annex32 Basic was so flexible.
This example was immediately included in my own translated manual in Dutch at bin$ and right$.
Tested and it works perfectly.

I started a long time ago with a ZX81 and a Commodore64 and then with Bascom AVR and also Arduino c which is too complicated for me. Then Annex32 Basic is the solution. :D

Re: How simple an 8 bit output?

Posted: Wed Aug 18, 2021 2:00 pm
by cicciocb
Interesting, maybe if other people are interested, you could share the doc translated with other Dutch users.