Skip to content

Instantly share code, notes, and snippets.

@Warrenn
Created October 14, 2020 20:02
Show Gist options
  • Save Warrenn/589c515c954016cb8ff42aff942fcb18 to your computer and use it in GitHub Desktop.
Save Warrenn/589c515c954016cb8ff42aff942fcb18 to your computer and use it in GitHub Desktop.
to and from decimal
int[] parts = Decimal.GetBits(value);
bool sign = (parts[3] & 0x80000000) != 0;
byte scale = (byte) ((parts[3] >> 16) & 0x7F);
Decimal newValue = new Decimal(parts[0], parts[1], parts[2], sign, scale);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment