15,790,807 members
See more:
```static void Main(string[] args)
{
long    virus ;

string c="";
for (int x = 0; x<=120; x++)
{
//   Console.WriteLine(b.ToString ());
virus = virus * 2;
//c = b.ToString();
}
Console.WriteLine((virus).ToString ());
}```

why give me zero?
Posted
Updated 29-Oct-10 21:49pm
v2

## Solution 2

you can use double, there is no other data type that is integer & gather than long. I think you multiply the value by 2^120. It will be out of range in long. You also can use string for integer multiplication.
```static void Main(string[] args)
{
double    virus ;

string c="";
for (int x = 0; x<=120; x++)
{
//   Console.WriteLine(b.ToString ());
virus = virus * 2;
//c = b.ToString();
}
Console.WriteLine((virus).ToString ());
}```

for string multiplication, you can see this link

Click

## Solution 4

That is because `long `is 64-bit signed `Integer`
and range of `long `datatype is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807, It can't count more then this

My advise would be to use `double` instead will give you value in Exponential format and will not be overflowed.

ok thnx for help
but i try double giving my 1.000000 so this fraction
what i do
shakil0304003 30-Oct-10 3:32am

## Solution 5

static void Main(string[] args)
{
double virus;
for (int x = 0; x <= 120; x++)
{
// Console.WriteLine(b.ToString ());
virus = virus * 2;
//c = b.ToString();
}
Console.WriteLine(virus);
}

It is giving solution in exponential form.

## Solution 6

What exactly do you want with it?
Creating a 128bit (or bigger) may do the trick if you want integers. It'll be faster than a BigNum, and it won't suffer from the accuracy problem of a double.

static void Main(string[] args)
{
long virus ;

string c="";
for (int x = 0; x<=120; x++)
{
// Console.WriteLine(b.ToString ());
virus = virus * 2;
//c = b.ToString();
}
Console.WriteLine((virus).ToString ());
}

when try this code give me error because the result is very large
thnx for help
[no name] 3-Nov-10 4:12am
yes.. that's because you actually Didn't do what I suggested, you just used a 64bit data type again.

## Solution 3

static void Main(string[] args)
{
long virus;
string c = "";
for (int x = 0; x <= 120; x++)
{
// Console.WriteLine(b.ToString ());
virus = virus * 2;

//c = b.ToString();
}
Console.WriteLine(virus);
}
in this case giving zero
plz try
thnx for help