In C#, I have a long that I need to convert to a decimal. The problem is that I want to put the decimal point at a specific position in the long.
For example, let's say I have the following number as a long:
long l = 123456789
When converting to a decimal with the floating point at the third position, I want to have the following:
decimal d = 123456.789
To give you an example, the function would ideally be something like the BigDecimal.valueOf in Java that allows you to give a long and a position to put the decimal point, and it returns the correct value.
I know one of the solution would be to format the long as a string with the correct decimal point position and then convert it back to a decimal. Another solution would be to multiply the long by 10-Decimal places wanted, but I'm wondering if there's a better alternative to this.