How to get bc to handle numbers in scientific (aka exponential) notation?

Unfortunately, bc doesn’t support scientific notation. However, it can be translated into a format that bc can handle, using extended regex as per POSIX in sed: sed -E ‘s/([+-]?[0-9.]+)[eE]\+?(-?)([0-9]+)/(\1*10^\2\3)/g’ <<<“$value” you can replace the “e” (or “e+”, if the exponent is positive) with “*10^”, which bc will promptly understand. This works even if the exponent … Read more

byte[] to unsigned BigInteger?

The remarks for the BigInteger constructor state that you can make sure any BigInteger created from a byte[] is unsigned if you append a 00 byte to the end of the array before calling the constructor. Note: the BigInteger constructor expects the array to be in little-endian order. Keep that in mind if you expect … Read more