Decimal to binary converter

You just made that up off the top of your head. Things don't work that way. Does this look familiar?:

        for (i = 0; i <= length; i++)

... it should...