This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Array to integer problem(integer too long).
- From: Brian Budge <brian dot budge at gmail dot com>
- To: Victor <victor at ambra dot ro>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 16 Feb 2005 12:20:38 +0100
- Subject: Re: Array to integer problem(integer too long).
- References: <4213263E.1060207@ambra.ro> <5b709458050216030325d35d39@mail.gmail.com> <42132C29.3080307@ambra.ro>
- Reply-to: Brian Budge <brian dot budge at gmail dot com>
Ah, okay. long int in most 32 bit system is the same as int. Usually
there is a type called long long which is 64 bits on 32 bit systems.
Brian
On Wed, 16 Feb 2005 13:19:05 +0200, Victor <victor@ambra.ro> wrote:
> Thank you.
> The problem is that I don't know what type to declare the numeric variable.
> If I try A simple program like this:
> #include <stdio.h>
> #include <stdlib.h>
> int main(int argc, char **argv) {
> long int test;
> test = 89126342536;
> }
> when I compile I get the following error:
> test.cpp: In function `int main(int, char**)':
> test.cpp:14: error: integer constant is too large for "long" type
>
> I know I must replace the line "long int test" with something else, but
> I don't know with what.
> Thank you.
>
> Brian Budge a scris:
>
> >Hi Victor -
> >
> >The number you specify is larger than can be held in a 32 bit integer.
> > Use atoll instead.
> >
> > Brian
> >
> >
> >On Wed, 16 Feb 2005 12:53:50 +0200, Victor <victor@ambra.ro> wrote:
> >
> >
> >>I have this simple script:
> >>
> >>#include <stdio.h>
> >>#include <stdlib.h>
> >>#include <string.h>
> >>int main(int argc, char **argv) {
> >> int test;
> >> char *numar = "89126342536";
> >> test = atoi(numar);
> >> printf("Test: %d", test);
> >>}
> >>
> >>I want to convert the string numar to integer.
> >>But the result - when I run the script is :
> >>Test: 2147483647
> >>and I would expect:
> >>Test: 89126342536.
> >>
> >>It seems that the number is too big.
> >>How can I solve this problem.
> >>
> >>Thank you.
> >>
> >>
> >>
> >>
> >
> >
> >
>
>