Created
July 7, 2023 13:47
-
-
Save ArtemAvramenko/3d7bdfc3ae7257738896c6c71ebb5ea2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var amount = 900m; | |
var currency = "μBTC"; | |
// https://en.wikipedia.org/wiki/Micro- | |
int prefixIndex = currency.Length > 3 ? "mμnpf".IndexOf(currency[0]) : -1; | |
if (prefixIndex >= 0) | |
{ | |
currency = currency[1..]; | |
amount /= (decimal)Math.Pow(1000, prefixIndex + 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment