I am researching this AS3 code that write a `BitString` into a `ByteArray`. Source: [JPGEncoder#writeBits()](https://github.com/mikechambers/as3corelib/blob/master/src/com/adobe/images/JPGEncoder.as#L239)

```
private var byteout:ByteArray;
private var bytenew:int = 0;
private var bytepos:int = 7;

private function writeBits(bs:BitString):void
{
    var value:int = bs.val;
    var posval:int = bs.len-1;
    while (posval >= 0) {
        if (value & uint(1 << posval)) {
            bytenew |= uint(1 << bytepos);
        }
        posval--;
        bytepos--;
        if (bytepos < 0) {
            if (bytenew == 0xFF) {
                writeByte(0xFF);
                writeByte(0);
            } else {
                writeByte(bytenew);
            }
            bytepos=7;
            bytenew=0;
        }
    }
}

```

But I don't understand part of the code. 

* What is `uint(1 << bytepos)`?
* What is the if condition `if (value & uint(1 << posval))`?
	+ I don't know whether the `&` is "and" bit operator, or "and" condition.
	+ Does `if(number)` in AS3 means `if(number != 0)` ?

What is these AS3 code equivalent in Java?