# How works with large integers ?

#### bogdana

Hello! I do not fully understand how it works with large integers. According to the code, the program receives a number from
1 * 10^15 to
1 * 10^16. So, when I write a number without 0 (for example, 3445674589632452), the code works as intended, and when I enter a number with 0 (for example, 3445674589630052), it gives me a negative number (-1048) instead 52. Please tell me what I should do.

C:
``````#include <stdio.h>
#include <cs50.h>
#include <math.h>

int main (void)
{
long  number  ;
number = get_long("Number: ");
if (number < 0 )
{
do
{
number = get_long("Number: ");
}
while ( number < 0 );
}
if (number > 0 && number < 10000000000000)
{
printf("INVALID\n");
return number;
}
if (number >= 100000000000000 && number < 1000000000000000)
{
printf("INVALID\n");
return number;
}
if ( number >= 100000000000000000)
{
printf("INVALID\n");
return number;
}
if (number == 0 )
{
printf("INVALID\n");
return number;
}
if (number >= 3400000000000000 && number < 3500000000000000)
{
do
{
number -=  1000000000000000;
}
while(number > 1000000000000000);
do
{
number -=  100000000000000;
}
while(number > 100000000000000);
do
{
number -= 10000000000000;
}
while(number > 10000000000000);
do
{
number -= 1000000000000;
}
while(number > 1000000000000);
do
{
number -= 100000000000;
}
while(number > 100000000000);
do
{
number -= 10000000000;
}
while(number > 10000000000);
do
{
number -= 1000000000;
}
while(number > 1000000000);
do
{
number -= 100000000;
}
while(number > 100000000);
do
{
number -= 10000000;
}
while(number > 10000000);
do
{
number -= 1000000;
}
while(number > 1000000);
do
{
number -= 100000;
}
while(number > 100000);
do
{
number -= 10000;
}
while(number > 10000);
do
{
number -= 1000;
}
while(number > 1000);
do
{
number -= 100;
}
while(number >= 100);
printf("%li\n" ,number );
printf("AMEX\n");
}``````

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

### Members online

No members online now.

473,835
Messages
2,569,801
Members
45,867
Latest member
MichaleMendoza