$num = int $num;
$num = (~abs($num))+1 if $num < 0;
You can get the same effect with $num |= 0; ...but... why? Why would you want two's complement behavior in other bases?
Truncating at $n bits is mathematically equivalent to:
$num %= 2 ** $n;
That's only meaningful for base-2. You can truncate at $n base-$b digits using this:
$num %= $b ** $n;
So -1 becomes 999999 in base-10 or 666666 in base-7. If you want, you can pick a big number of digits that still fits in a double-precision float like this:
$num %= $base ** int(36.73/log($base));