Sounds like you need some big integer library integer functions. I only know of one of these written in a basic dialect. But there may be one that already exists for PBP?