aboutsummaryrefslogtreecommitdiff
path: root/csharp/TestBed/BclDecimal.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/TestBed/BclDecimal.cs')
-rw-r--r--csharp/TestBed/BclDecimal.cs14
1 files changed, 14 insertions, 0 deletions
diff --git a/csharp/TestBed/BclDecimal.cs b/csharp/TestBed/BclDecimal.cs
new file mode 100644
index 00000000..c9f7ebbb
--- /dev/null
+++ b/csharp/TestBed/BclDecimal.cs
@@ -0,0 +1,14 @@
+namespace Google.ProtocolBuffers.Bcl {
+ public partial class Decimal {
+ public decimal ToDecimal() {
+ if (Lo == 0 && Hi == 0) return decimal.Zero;
+
+ int lo = (int)(Lo & 0xFFFFFFFFL),
+ mid = (int)((Lo >> 32) & 0xFFFFFFFFL),
+ hi = (int)Hi;
+ bool isNeg = (SignScale & 0x0001) == 0x0001;
+ byte scale = (byte)((SignScale & 0x01FE) >> 1);
+ return new decimal(lo, mid, hi, isNeg, scale);
+ }
+ }
+}