View previous topic :: View next topic |
Author |
Message |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
is this ANSI acceptable or not ??? [solved] -Octal confused |
Posted: Wed Jul 11, 2012 2:44 pm |
|
|
version 4.134
Quote: |
CONST BYTE ok[4]={254,012,42,048}
Code: |
will not compile , errors - with "numeric expected"
where as
|
CONST BYTE ok[4]={254,12,42,48}
Code: |
DOES .... ?????
what kind of parser can't handle a leading zero ??
|
|
Last edited by asmboy on Wed Jul 11, 2012 6:21 pm; edited 1 time in total |
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Wed Jul 11, 2012 3:37 pm |
|
|
Wouldn't 012 be 12 Octal and not 12 decimal? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jul 11, 2012 4:22 pm |
|
|
Compile it in MSVC++ 6.0 (as a C file):
Code: |
#include <stdio.h>
//======================================
void main(void)
{
const unsigned char ok[4]={254,012,42,048};
while(1);
}
|
It does not like illegal digits for numbers specified in Octal format (base 8):
Quote: |
C:\Program Files\Microsoft Visual Studio\MyProjects\Test\Test.c(8) :
error C2041: illegal digit '8' for base '8'
Error executing cl.exe. |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Wed Jul 11, 2012 5:49 pm |
|
|
yup typos can bite real bad.
O000O0O0
after a few hours ohs look like zeros.....
especially in some fonts !!!
It'd be nice to have zeros with a slash forced through them.
or at least the option to allow it for us , um, older guys with bifocals !!
jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Jul 11, 2012 6:22 pm |
|
|
thanks for the helpful explanation.
that number base had slipped from my pea brain
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Wed Jul 11, 2012 7:08 pm |
|
|
hmmm..not a typo...man my eyes are getting bad...still looks like a zero not a big oh to me, sigh, getting old sucks..
Last octal I did was in PDP-11 systems...back in '75...must admit it might not be 'common' anymore....
I do recall some systems allowing you to set the 'default' base for numbers entered in a program which is kinda handy.
I have used leading zeros in 3 digit decimal numbers to keep things visually aligned, making it easier to see 'funny' numbers. |
|
|
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Wed Jul 11, 2012 8:34 pm |
|
|
I still think in octal these days -- too many hours spent hand coding 8080/Z-80 assembler. Those processors were octal in opcode design - 176 was mov A,M while 167 was the reverse - mov M,A. Interestingly enough, the instruction for MOV M,M (166) was the HALT instruction. Used to have a little cardboard slide rule for figuring the opcodes for all the instructions ... come to think of it, I probably still have it down stairs :-)
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
|
|