Error invalid digit 8 in octal constant

Hi. I came across a strange errormessage and it might be a bug in the 1.0.5 version of the arduino software. The part of the code that gets the error looks like this: " if (i == 01) catchd01 =...

@sjoch

Hi.

I came across a strange errormessage and it might be a bug in the 1.0.5 version of the arduino software.

The part of the code that gets the error looks like this:
» if (i == 01) catchd01 = t;
if (i == 02) catchd02 = t;
if (i == 03) catchd03 = t;
if (i == 04) catchd04 = t;
if (i == 05) catchd05 = t;
if (i == 06) catchd06 = t;
if (i == 07) catchd07 = t;
if (i == 08) catchd08 = t;
if (i == 09) catchd09 = t;
«

And the compiler only complains on the last 2 lines.

error: invalid digit «8» in octal constant
error: invalid digit «9» in octal constant

So, whats wrong? it compiles good if all zeros are removed from the i == part.
But shouldnt it complain on all 9 lines if its the zero that is the problem.. why just 8 and 9?

@lestofante

because the compiler thinks you are using OCTAL number, and octal number
goes from 0 to 7.
Also, if this was a bug, was a COMPILER fault, you should had ask to
avr-gcc’s folks.

2013/6/30 sjoch notifications@github.com

Hi.

I came across a strange errormessage and it might be a bug in the 1.0.5
version of the arduino software.

The part of the code that gets the error looks like this:
» if (i == 01) catchd01 = t;
if (i == 02) catchd02 = t;
if (i == 03) catchd03 = t;
if (i == 04) catchd04 = t;
if (i == 05) catchd05 = t;
if (i == 06) catchd06 = t;
if (i == 07) catchd07 = t;
if (i == 08) catchd08 = t;
if (i == 09) catchd09 = t;
«

And the compiler only complains on the last 2 lines.

error: invalid digit «8» in octal constant
error: invalid digit «9» in octal constant

So, whats wrong? it compiles good if all zeros are removed from the i ==
part.
But shouldnt it complain on all 9 lines if its the zero that is the
problem.. why just 8 and 9?


Reply to this email directly or view it on GitHubhttps://github.com//issues/1490
.

@cmaglie

A constant number starting with «0» is interpreted as octal by the compiler, you must write «8» instead of «08».
BTW programming questions should be addressed to the forum.

http://forum.arduino.cc

C

@srknthcse

Error solved but i need clear explanation can anybody explain .thank you

@shaishu03

Error resuelto, pero necesito una explicación clara, ¿alguien puede explicarme? Gracias.

como lo solucionaste?

@arduino
arduino

locked as resolved and limited conversation to collaborators

Oct 21, 2022

int arr[20][20] = {
                    {08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08},
                    {49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00},
                    {81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65},
                    {52,70,95,23,04,60,11,42,69,24,68,56,01,32,56,71,37,02,36,91},
                    {22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80},
                    {24,47,32,60,99,03,45,02,44,75,33,53,78,36,84,20,35,17,12,50},
                    {32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70},
                    {67,26,20,68,02,62,12,20,95,63,94,39,63,08,40,91,66,49,94,21},
                    {24,55,58,05,66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72},
                    {21,36,23,09,75,00,76,44,20,45,35,14,00,61,33,97,34,31,33,95},
                    {78,17,53,28,22,75,31,67,15,94,03,80,04,62,16,14,09,53,56,92},
                    {16,39,05,42,96,35,31,47,55,58,88,24,00,17,54,24,36,29,85,57},
                    {86,56,00,48,35,71,89,07,05,44,44,37,44,60,21,58,51,54,17,58},
                    {19,80,81,68,05,94,47,69,28,73,92,13,86,52,17,77,04,89,55,40},
                    {04,52,08,83,97,35,99,16,07,97,57,32,16,26,26,79,33,27,98,66},
                    {88,36,68,87,57,62,20,72,03,46,33,67,46,55,12,32,63,93,53,69},
                    {04,42,16,73,38,25,39,11,24,94,72,18,08,46,29,32,40,62,76,36},
                    {20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,04,36,16},
                    {20,73,35,29,78,31,90,01,74,31,49,71,48,86,81,16,23,57,05,54},
                    {01,70,54,71,83,51,54,69,16,92,33,48,61,43,52,01,89,19,67,48}
                  };

I get the following error

q11.c:8:10: error: invalid digit "8" in octal constant
q11.c:8:67: error: invalid digit "8" in octal constant
q11.c:15:49: error: invalid digit "8" in octal constant
q11.c:17:19: error: invalid digit "9" in octal constant
q11.c:18:58: error: invalid digit "9" in octal constant
q11.c:22:16: error: invalid digit "8" in octal constant
q11.c:24:46: error: invalid digit "8" in octal constant

  1. Скетч для робота с ик приемником, ide ругается:invalid digit «8» in octal constant
    Понять в чем проблема смог, а как решить ее не могу понять все еще.
    Скетч:

    const long IR_COMMAND_FORWARD_CODES[] = { 377281, 7503, 2 };
    const long IR_COMMAND_BACKWARD_CODES[] = { 377282, 1583, 8 };
    const long IR_COMMAND_TURN_LEFT_CODES[] = { 377278, 0783, 4 };
    const long IR_COMMAND_TURN_RIGHT_CODES[] = { 377279, 7103, 6 };
    const long IR_COMMAND_FORWARD_LEFT_CODES[] = { 377278, 4863, 1 };
    const long IR_COMMAND_FORWARD_RIGHT_CODES[] = { 377280, 1183, 3 };
    const long IR_COMMAND_BACKWARD_LEFT_CODES[] = { 377280, 5263, 9 };
    const long IR_COMMAND_BACKWARD_RIGHT_CODES[] = { 377278, 8943, 7 };
    const long IR_COMMAND_STOP_CODES[] = { 377281, 3423, 5 };
    const long IR_COMMAND_VERY_SLOW_CODES[] = { 377280, 3223, 40 };
    const long IR_COMMAND_SLOW_CODES[] = {377281, 9543, 43 };
    const long IR_COMMAND_FAST_CODES[] = { 377278, 6903, 26 };
    const long IR_COMMAND_VERY_FAST_CODES[] = { 377279, 0473, 27 };
     
  2. А что вам непонятно? 0 перед числом говорит, что это число — в восьмеричной системе счисления, а там, как известно, нет цифры 8.

    0x перед числом — говорит, что это число в шестнадцатеричной системе счисления.

    Короче — уберите 0 спереди у чисел 0783 и 0473 — они там не нужны.

Feeds

HomePopular

Topics

ValheimGenshin ImpactMinecraftPokimaneHalo InfiniteCall of Duty: WarzonePath of ExileHollow Knight: SilksongEscape from TarkovWatch Dogs: Legion

NFLNBAMegan AndersonAtlanta HawksLos Angeles LakersBoston CelticsArsenal F.C.Philadelphia 76ersPremier LeagueUFC

GameStopModernaPfizerJohnson & JohnsonAstraZenecaWalgreensBest BuyNovavaxSpaceXTesla

CardanoDogecoinAlgorandBitcoinLitecoinBasic Attention TokenBitcoin Cash

The Real Housewives of AtlantaThe BachelorSister Wives90 Day FianceWife SwapThe Amazing Race AustraliaMarried at First SightThe Real Housewives of DallasMy 600-lb LifeLast Week Tonight with John Oliver

Kim KardashianDoja CatIggy AzaleaAnya Taylor-JoyJamie Lee CurtisNatalie PortmanHenry CavillMillie Bobby BrownTom HiddlestonKeanu Reeves

Animals and PetsAnimeArtCars and Motor VehiclesCrafts and DIYCulture, Race, and EthnicityEthics and PhilosophyFashionFood and DrinkHistoryHobbiesLawLearning and EducationMilitaryMoviesMusicPlacePodcasts and StreamersPoliticsProgrammingReading, Writing, and LiteratureReligion and SpiritualityScienceTabletop GamesTechnologyTravel

Create an account to follow your favorite communities and start taking part in conversations.

Cplusplus

Posts

r/Cplusplus

1

Posted by7 years ago

here is the code: if (airc == 08) { grid[0][7] == ‘A’ ;}

any help is much appreciated!

2 comments

100% Upvoted

level 1

· 7 yr. ago

An integer literal with a leading zero is interpreted as a value in octal (base 8.) As such it can only contain the digits zero through seven. Remove the leading zero.

7

level 2

Op · 7 yr. ago

ok thank you!

1

About Community

Subreddit Icon

r/Cplusplus

C++, basically.

Created Jan 25, 2008


32.8k

Master Coders

25

Reading Holy Scripts

Top 5%

Ranked by Size


Top posts november 22nd 2015Top posts of november, 2015Top posts 2015

User AgreementPrivacy policy

Content policyModerator Code of Conduct

Reddit Inc © 2023. All rights reserved


Recommended Answers

I’m taking the time from an accessor function and if it’s from 0-9, so it displays correctly the hour time position, I have the following statements in my main body:

if (clock1.getHour() == 00)
    cout<<"The hour of clock1 is 00"<<endl;
    
    else if (clock1.getHour() == 01)
    cout<<"The hour of …

Jump to Post

No, all of the 0’s in the lines are all 0’s, I double checked. At no time did I declare octal constants. My goal is basically to get it to print out 08, 09 for the hour parameter without converting it to a string.

Thanks though, I made 010 for …

Jump to Post

All 5 Replies

Member Avatar


VernonDozier

2,218



Posting Expert



Featured Poster


14 Years Ago

I’m taking the time from an accessor function and if it’s from 0-9, so it displays correctly the hour time position, I have the following statements in my main body:

if (clock1.getHour() == 00)
    cout<<"The hour of clock1 is 00"<<endl;
    
    else if (clock1.getHour() == 01)
    cout<<"The hour of clock1 is 01"<<endl;
    
    else if (clock1.getHour() == 02)
    cout<<"The hour of clock1 is 03"<<endl;
    
  ...   ...  .... ...
    
    else if (clock1.getHour() == 08)
    cout<<"The hour of clock1 is 08"<<endl;
    
    else if(clock1.getHour() == 09)
    cout<<"The hour of clock1 is 09"<<endl;

    else 
    cout<<"The hour of clock1 is "<<clock1.getHour()<<endl;

This works great and it displays, except when I get to 8 and 9. I get two errors, invalid digit «8» & «9» in octal constant. They also don’t appear in purple as the rest of the ints do in else if statements, just black.

The syntax is exactly the same as the rest of the statements. I don’t get why it would all of the sudden act up now. If I comment them out, it runs.

Thanks.

Well if it’s an octal constant, then the only valid digits are 0 though 7, so O8 is illegal since 8 isn’t an octal digit. Do you want octal constants? Is that a typo : is it supposed to be the number 0 rather than the letter O, which stands for Octal base in this context? Why not just make it:

else if (clock1.getHour() == 8)

If you want the above statement in octal, i guess it would be:

else if (clock1.getHour() == O10)

since O10 is the equivalent of 8. Do you have the letter O in there on purpose?

Member Avatar

14 Years Ago

No, all of the 0’s in the lines are all 0’s, I double checked. At no time did I declare octal constants. My goal is basically to get it to print out 08, 09 for the hour parameter without converting it to a string.

Thanks though, I made 010 for 8 and 011 for 9 and is correctly displaying 08 and 09 for the hour position.

Member Avatar


VernonDozier

2,218



Posting Expert



Featured Poster


14 Years Ago

No, all of the 0’s in the lines are all 0’s, I double checked. At no time did I declare octal constants. My goal is basically to get it to print out 08, 09 for the hour parameter without converting it to a string.

Thanks though, I made 010 for 8 and 011 for 9 and is correctly displaying 08 and 09 for the hour position.

Hmm, I just cut and pasted your code again and you’re right, they are zeroes in your code, not the letter O. Maybe I copied and pasted wrong last time or typed in the letter O without realizing it last time. I’m not sure. The error suggests that there was a letter O in there somewhere, not a zero. I don’t know how you would get the error otherwise and if you go back and forth changing from the letter O o a zero and vice versa, it will compile successfully or not based on that. Not sure what the deal is, but if it works now, great.

Member Avatar


dougy83

74



Posting Whiz in Training


14 Years Ago

In C/C++, octal numbers are prefixed with 0 (zero), in the same manner as hexadecimal numbers are prefixed with 0x (zero, ex).

Using the letter O (oh) does not specify an octal digit, but will be an (undefined) variable name.

I believe the answer to the OP’s question is to get rid of all zeros preceeding any number, so that it is read as decimal and not octal.

Member Avatar


VernonDozier

2,218



Posting Expert



Featured Poster


14 Years Ago

In C/C++, octal numbers are prefixed with 0 (zero), in the same manner as hexadecimal numbers are prefixed with 0x (zero, ex).

Using the letter O (oh) does not specify an octal digit, but will be an (undefined) variable name.

I believe the answer to the OP’s question is to get rid of all zeros preceeding any number, so that it is read as decimal and not octal.

You’re right dougy. I’m embarrassed. I forgot that and wasn’t really paying attention and posted and got the letter O and number 0 completely backwards! Twice!


Reply to this topic

Be a part of the DaniWeb community

We’re a friendly, industry-focused community of developers, IT pros, digital marketers,
and technology enthusiasts meeting, networking, learning, and sharing knowledge.

int arr[20][20] = {
                    {08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08},
                    {49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00},
                    {81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65},
                    {52,70,95,23,04,60,11,42,69,24,68,56,01,32,56,71,37,02,36,91},
                    {22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80},
                    {24,47,32,60,99,03,45,02,44,75,33,53,78,36,84,20,35,17,12,50},
                    {32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70},
                    {67,26,20,68,02,62,12,20,95,63,94,39,63,08,40,91,66,49,94,21},
                    {24,55,58,05,66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72},
                    {21,36,23,09,75,00,76,44,20,45,35,14,00,61,33,97,34,31,33,95},
                    {78,17,53,28,22,75,31,67,15,94,03,80,04,62,16,14,09,53,56,92},
                    {16,39,05,42,96,35,31,47,55,58,88,24,00,17,54,24,36,29,85,57},
                    {86,56,00,48,35,71,89,07,05,44,44,37,44,60,21,58,51,54,17,58},
                    {19,80,81,68,05,94,47,69,28,73,92,13,86,52,17,77,04,89,55,40},
                    {04,52,08,83,97,35,99,16,07,97,57,32,16,26,26,79,33,27,98,66},
                    {88,36,68,87,57,62,20,72,03,46,33,67,46,55,12,32,63,93,53,69},
                    {04,42,16,73,38,25,39,11,24,94,72,18,08,46,29,32,40,62,76,36},
                    {20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,04,36,16},
                    {20,73,35,29,78,31,90,01,74,31,49,71,48,86,81,16,23,57,05,54},
                    {01,70,54,71,83,51,54,69,16,92,33,48,61,43,52,01,89,19,67,48}
                  };

Я получаю следующую ошибку

q11.c:8:10: error: invalid digit "8" in octal constant
q11.c:8:67: error: invalid digit "8" in octal constant
q11.c:15:49: error: invalid digit "8" in octal constant
q11.c:17:19: error: invalid digit "9" in octal constant
q11.c:18:58: error: invalid digit "9" in octal constant
q11.c:22:16: error: invalid digit "8" in octal constant
q11.c:24:46: error: invalid digit "8" in octal constant

Home Repetier-Firmware Bug Reports

Error compilation «invalid digit «8» in octal constant»

Hi,

downloaded the last dev version today i an get the next error:
Arduino: 1.6.5 (Windows 7), Board: «Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)»
Extruder.cpp:1333: error: invalid digit «8» in octal constant
     {0,0},{908,8},{941.16,410*8},{982,08,20*8},{1015,8*30},{1048,8*40},{1080,8*50},{1113,8*60},{1146,8*70},{1178,8*80},{11211,8*90},{1276,8*110},{1318,8*120}
invalid digit «8» in octal constant
const short temptable_13[NUMTEMPS_12][2] PROGMEM =
    {0,0},{908,8},{941.16,410*8},{982,08,20*8},{1015,8*30},{1048,8*40},{1080,8*50},{1113,8*60},{1146,8*70},{1178,8*80},{11211,8*90},{1276,8*110},{1318,8*120}
    ,{1670,8*230},{2455,8*500},{3445,8*900},{3666,8*1000},{3871,8*1100},{4095,8*2000}
the value of temptable_13[4] = {982,08,20*8}
the correct is not something like  {982.08,20*8}?

Понравилась статья? Поделить с друзьями:
  • Error invalid data directory postgresql
  • Error invalid data directory for cluster 12 main
  • Error invalid conversion from const char to int fpermissive
  • Error invalid constructor arguments provided please verify that they are in abi encoded format
  • Error invalid combination of opcode and operands nasm