You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Extensions/BitConverterExtensions.cs

26 lines
736 B

6 years ago
using System;
using System.Collections.Generic;
namespace ZeroLevel.Services.Extensions
{
public static class BitConverterExt
{
public static byte[] GetBytes(this Decimal dec)
{
var bites = decimal.GetBits(dec);
var bytes = new List<byte>();
foreach (var i in bites)
{
bytes.AddRange(BitConverter.GetBytes(i));
}
return bytes.ToArray();
}
6 years ago
public static decimal ToDecimal(this int[] parts)
6 years ago
{
6 years ago
bool sign = (parts[3] & 0x80000000) != 0;
byte scale = (byte)((parts[3] >> 16) & 0x7F);
return new Decimal(parts[0], parts[1], parts[2], sign, scale);
6 years ago
}
}
}

Powered by TurnKey Linux.