PHP Cantor implementation using BCMath extension