Converting Float Base-10 value to Base 2/8/16, then to Bytes

On the safe side, I’m afraid you need to create your own encoding package.

big.Float is not going to help much in base number conversion apart from holding large numbers while math package only offers exp2 functionality. Both accuracy can be different, case-by-case basis.

You can do a code reference for the exponent base conversion: - The Go Programming Language

Another good option to refer spektre’s algorithm for base conversion. Link: java - Converting base of floating point number without losing precision - Stack Overflow

1 Like