Go Down

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

#### kopite

#15
##### Dec 20, 2012, 11:39 pm
Quote
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.

#### kopite

#16
##### Dec 20, 2012, 11:41 pm
Quote
You decided to ask the same question again, huh?

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

#### lloyddean

#17
##### Dec 21, 2012, 06:09 am
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

#### nickgammon

#18
##### Dec 21, 2012, 07:35 am
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!