This is the Logic for converting a Decimal number to Binary.

I'm having confusion in getting it.

It would be great if someone make me understand this.

for ( long decimal = d ; decimal > 0 ; decimal/=2 )

```
{
binary = decimal%2 + binary ;
}
```

If d=4 then in fisrt go:

4/2=2 and 4%2=0

So, binary = decimal%2 + binary => binary = 0 + (what will be the value of binary here??)