CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

is this ANSI acceptable or not ??? [solved] -Octal confused

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

is this ANSI acceptable or not ??? [solved] -Octal confused
PostPosted: Wed Jul 11, 2012 2:44 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jul 11, 2012 3:37 pm     Reply with quote

Wouldn't 012 be 12 Octal and not 12 decimal?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 11, 2012 4:22 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jul 11, 2012 5:49 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jul 11, 2012 5:54 pm     Reply with quote

It's not a typo. It's just a mistake. Example:
http://stackoverflow.com/questions/8459030/whats-wrong-with-array-declaration-invalid-digit-in-octal-constant
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Jul 11, 2012 6:22 pm     Reply with quote

thanks for the helpful explanation.

that number base had slipped from my pea brain
Very Happy Very Happy
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jul 11, 2012 7:08 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jul 11, 2012 8:34 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group