Re: [Dev-C++] numeric constant contains digits beyond the radix
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jason H. <jas...@bt...> - 2002-01-14 00:25:13
|
When you use zero as a prefix to a number the compiler expects the number to
be in octal (base 8), just like when you put 0x before a number it is in
hexadecimal form (base 16), therefore 08 and 09 cannot be valid as only
digits 0 through to 7 are allowed in octal notation.
When you write 07, you are not saying 7d (decimal) you are saying 7o (octal)
they just happen to be the same value. If you were to write 0256 in C/C++,
then in decimal that value would be 2*8*8 + 5*8 + 6 = 128 + 40 + 6 = 174d.
All this is related to the maths used in computers (which use binary
internally). I think that some programming books tend to gloss over the
relations of binary, octal, and hexadecimal use in programming.
Jason.
----- Original Message -----
From: "Clovis Sena" <cs...@it...>
To: <dev...@li...>
Sent: Friday, January 11, 2002 5:56 PM
Subject: Re: [Dev-C++] numeric constant contains digits beyond the radix
> asnswering myself:
>
> a search at google, and I found this from gcc mailling lists :
>
> <snip>
>
> This is not a bug, a number in C prefix with 0 is in base 8 not base 10,
> can someone close this bug?
>
> <snip>
>
> so it is just removing the 0 from 08, and it compiles ok. Just dont
> understand why with other mumbers like 02, 05, 06 and 07 ( see bellow ) we
> do not have this problem.
>
> gotoxy(10,05);
> textcolor(WHITE);
> textbackground(BLUE);
> printf("1 - Calculadora:");
> gotoxy(10,06);
> printf("2 - Backup" );
> gotoxy(10,07);
> printf("3 - Restaura Backup");
> gotoxy(10,8);
> printf("4 - Importa Dados");
>
> thanks.
>
> Clovis.
>
>
> At 14:59 11/01/02 -0200, Clovis Sena wrote:
> >hi all
> >
> >
> >does anyone knows why I got this error:
> >
> >gotoxy(10,08);
> >printf("4 - Cartao (S/N) : N");
> >gotoxy(10,09);
> >printf("5 - TEF - Transferencia Eletronica de Fundos (S/N) : N");
> >
> >compile error:
> >
> >637 teste8.1.cpp
> > numeric constant contains digits beyond the radix
> >
> >if iI change the above lines to gotoxy(10,10); it works ok. It seems
that
> >could not printf to line 08 and 09.
> >
> >
> >
> >-------------------------------------------------
> >Clovis Sena
> >Itautec.Com Servicos
> >Suporte Tecnico Software/Hardware
> >---------------
> >Email: cs...@it...
> >Fone : 0xx81-3421-1126
> >Fax : 0xx81-3421-4988
> >-------------------------------------------------
> >
> >
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> -------------------------------------------------
> Clovis Sena
> Itautec.Com Servicos
> Suporte Tecnico Software/Hardware
> ---------------
> Email: cs...@it...
> Fone : 0xx81-3421-1126
> Fax : 0xx81-3421-4988
> -------------------------------------------------
>
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|