Question: This in javascript gives 73014902784

```
cs = [ 4, 4, 4, 8, 9];
var v, i, o, s = 1<<cs[0]|1<<cs[1]|1<<cs[2]|1<<cs[3]|1<<cs[4];
for(i=-1, v=o=0; i<5; i++, o=Math.pow(2,cs[i]*4)){
    v += o*(((v/o)&15)+1);
}

```

Because c++ doesn't handle division by zero I wrote a divide function

```
int divide(int a, int b) 
{
    if (b == 0) 
    { 
        return 0; 
    }

    return a / b; 
}

int v, i, o, s = 1 << cs[0] | 1 << cs[1] | 1 << cs[2] | 1 << cs[3] | 1 << cs[4];
for (i = -1, v = o = 0; i < 5; i++, o = pow(2, cs[i] * 4)) {
    v += o*((divide(v,o) & 15) + 1);
}

```

But this gives me 458752. Why so? Have checked this a million times.

Answer: 
I suspect your problem is that JavaScript represents all numbers in 64-bit floating-point format, while your C++ variables are all defined as (what are probably 16-bit) int's.
JavaScript is wrong at the computation and your C++ `divide` function is wrong too.

* Something other than 0 divided by zero is infinity. Zero/zero is undefined, it can be really anything (0, 1, 2, 10, 2000, infinity, ...)
* There's a reason why C++ don't handle division by zero, it's tricky. Infinity is not a number, it's a concept, some mathematical operations don't work with it.

The bitwise operator `&` is a great example, since infinity is defined arbitrarily (kind of like zero on floating point), the result of the bitwise is also arbitrary.

Think of infinity as a very large ***thing*** (not a number!) and you don't know *exactly* what that thing is. That is, you take a number and divide it by a very small number, it should give you a **very large thing**, but you don't have a real representation for it.