Hi

I use Dev - C++

and i d like to ask you cause i dont seem to figure that out, how can i store a 12 digit number?

For example lets say this is the number 930342900243

How can i write a program that would print that number using a variable?

Thanks

so you mean use long long or __int64 like for example

long long variable; or __int 64 variable;

variable = value;

display variable?

if yes that didnt work for me in both cases.

If im wrong can you please send some code so that i can understand better what you mean?

thanks

#include <stdio.h>

int main( void ) {
  // how can i store a 12 digit number?
  long long num = 123456789123;

  // print that number using a variable
  printf( "%lld", num );

  return 0;
}

I think that's right, hope this helps.

i used your code but again:

[Warning] integer constant is too large for "long" type

i think i should stop using dev, maybe its dev's problem? Should i use another compiler?

any recommendation?

long long blahblahquack = 930342;

blahblahquack *= 1000000;

blahblahquack += 900243;

do_something(blahblahquack);


-----

or you could make a function:

long long from_thousands(int a, int b, int c, int d, int e){
long long ans = 0;
ans += a; ans *= 1000;
ans += b; ans *= 1000;
ans += c; ans *= 1000;
ans += d; ans *= 1000;
ans += e;
}

long long blahblahquack = from_thousands(0,930,342,900,243);

If you want to code it in C#, the code is cleaner -- use an object[] .

>If you want to code it in C#, the code is cleaner -- use an object[]
Don't bother suggesting another language, we're in the C forum and we can assume the OP wants to use C, unless he says so himself that he's undecided.

Either way, that post didn't solve his problem. I don't use Dev, but your best bet would be to search the problem on google.

There are many Dev IDE's but the typical Dev refers to Visual Studio 6.0 not newer! That version did not support long long. And math with 64-bit data had to be done in assembly language!

It also had trouble with long int. And it equated long the same as int thus both 32-bit.

One thing you could try:

long long num = 123456789123[B]ll[/B];

Just a guess though.

ll looks too much like 11. LL is easier to see as a literal suffix.

And in case of positive numbers only then consider making it unsigned as well :)
And IMO using LL it's easier to recognize it as a literal (as already mentioned) (there's no doubt possible then) ...

In C99 mode, with gcc 3.4.5:

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main()
{
   int64_t value = 930342900243;
   printf("value = %" PRId64 "\n", value);
   return 0;
}

/* my output
value = 930342900243
*/
This article has been dead for over six months. Start a new discussion instead.