# how to calculate billion number

• 10-14-2005
mrmamon
how to calculate billion number
i want write program to calculate billion number but when i input a lot of number my program will show negative number :confused:

this my code

Code:

```int main() {     double long a,b,c;         scanf ("%d",&a);     scanf ("%d",&b);     c=a+b;     printf("%d",c);         getch();     }```
why don't work?

plz help me :eek:

ps.sorry my eng is not strong.
• 10-15-2005
Salem
Because normal 32 bit integers (the most common) have a max positive value of 2147483647

If you want something much bigger, tell us which compiler you're using.
• 10-15-2005
mrmamon
i use turbo c++

thx for u help :o
• 10-15-2005
Prelude
>i use turbo c++
Start by getting a newer compiler. Do you have any idea how old Turbo C++ is?
• 10-15-2005
ryeguy
i think it came out in '91
• 10-15-2005
dwks
Exactly. For starters, use a long instead of an int.
• 10-15-2005
Sintu
int can only hold values of -32,768 through 32,767. Try compling this bit of code (Taken from SAMS Teach Yourself C++ In 24 Hours)
Code:

```#include <iostream> int main() {       int smallNumber;       smallNumber = 32767;       std::cout << "small number:" << smallNumber << std::endl;       smallNumber++;       std::cout << "small number" << smallNumber << std::endl;       smallNumber++;       std::cout << "small number" << smallNumber << std::endl;       return 0; }```
When you see the output, you will notice that after I increment the number with ++, it wraps around to the smallest number it can hold, which is -32767. This is called (you guessed it) "Wrap Around." Use an unsigned long int for positive #s up to 4,294,967,295. Hope it helps, a fellow n00b programmer, Sintu :D
• 10-15-2005
Bajanine
How about a 'long long int' or is this not standard.
• 10-16-2005
Dweia
long long isn't standard but it's reasonably well supported I think.
• 10-16-2005
Salem
Not on the OP's fossil compiler it isn't.