How do I convert from decimal to binary

Using unpack;

    $bin = unpack("B*", pack("N", 3735928559));
Using Bit::Vector:

    use Bit::Vector;
    $vec = Bit::Vector->new_Dec(32, -559038737);
    $bin = $vec->to_Bin();
The remaining transformations (e.g. hex -> oct, bin -> hex, etc.) are left as an exercise to the inclined reader.


Back to perlfaq4