move out BigInt format conversion code