could you not detect if the 32nd bit is 1 at $ch = ((($ch/7) << 2) | (($ch%13)&7)); and then set it to 0. and restore the CORRECT bit afterwards? you would need to calculate what that bit should be but it should work. i am of course assuming its generating the incorrect BINARY rather than incorect Decimal output at that point of course.
as long as the binary value remains correct it does not matter if it is unsigned or not.
$ch = (((((int)($ch/7)) << 2) | (($ch%13)&7));
(int) may be needed if float based weirdness happens.