Go Down

Topic: Bin Dec Hex Oct Converter (Read 6402 times) previous topic - next topic


That's an interesting question.
What if you entered 011?
Would you interpret as 3 or 9?

Sorry, I wasnt clear enough. I was using 012 as an example. I want the user to input anything as long as it is read an octal value.


You decided to ask the same question again, huh?

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Yeah, I used your sample with some modifications but the program did not work. So I thought i'd ask again to see if anyone else new. Forgot the house rules.

Apologies Nick


Number bases are usually denoted with a prefix.

Octal values have a leading '0' character with following characters limited to '0', '1', '2', '3', '4', '5', '6' and '7'.

010 is decimal 8

Hex values have a leading two character indicator of '0x' or '0X' with the following characters limited to '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a' (or 'A'), 'b' (or 'B'), 'c' (or 'C'), 'd' (or 'D'), 'e' (or 'E'), 'f' (or 'F').

0xF is decimal 15

Binary numbers have a leading '0b' with the following characters limited to '0' and '1'.

0b1000 is decimal 8


He's talking about user-input not compiler input. I gave an example sketch on the previous page, not much reaction to that however.
Please post technical questions on the forum, not by personal message. Thanks!

More info:


The same convention can be applied to user input as there is no magic way other than in indication by the user as to the input number base.

My early 6502 experience forgo's octal and has '$' proceeding hex values and '%' proceeding binary values.  Just pick something ..., anything consistent should do.

Go Up