I have a function which works very well for not too big values:
public BigInteger GetFrom(decimal value)
{
var decimalPlaces = 20;
var factor = (decimal) Math.Pow(10, decimalPlaces);
return new BigInteger(value * factor);
}
It transforms correctly:
123m = 12300000000000000000000
123.123456789m = 12312345678900000000000
0.123m = 12300000000000000000
0.123456789m = 12345678900000000000
0.123456789012345678902345678901234567890m = 12345678901234567890
1.123456789012345678902345678901234567890m = 112345678901234567890
But trows for something like: 12345678901234567890.12345678901234567890m. Of course because 12345678901234567890.12345678901234567890m * Math.Pow(10, 20) is too big for a decimal, but I don't need this as decimal I need this as BigInteger like the examples before
12345678901234567890.12345678901234567890m = 1234567890123456789012345678901234567890
Buy, I am not sure about what/how is the best way to solve this problem...