public static bool ConvertToBit(string hex) { Hexadecimals h = new Hexadecimals(); var bytes = h.FromHex(hex); return (bytes[0] & 1) != 0; }
public static double ConvertToMoney(string hex) { Hexadecimals h = new Hexadecimals(); Byte[] bytes = h.FromHex(hex); if (BitConverter.IsLittleEndian) { bytes = bytes.Reverse().ToArray(); } return BitConverter.ToInt64(bytes, 0) / 10000d; }
public static float ConvertToReal(string hex) { Hexadecimals h = new Hexadecimals(); var bytes = h.FromHex(hex); if (BitConverter.IsLittleEndian) { bytes = bytes.Reverse().ToArray(); } return BitConverter.ToSingle(bytes, 0); }
public static string ToSmallDateTime(string hexadecimal) { Hexadecimals h = new Hexadecimals(); var fechabase = "1900-01-01 00:00"; var date = DateTime.ParseExact(fechabase, "yyyy-MM-dd HH:mm", null); date = date.AddDays(BitConverter.ToUInt16(h.FromHex(hexadecimal), 2)); date = date.AddSeconds(BitConverter.ToUInt16(h.FromHex(hexadecimal), 0) / 300); return date.ToString(); }
public static int ToInt(string hexadecimal) { int x; Hexadecimals h = new Hexadecimals();; string hex = h.backwards(hexadecimal); x = int.Parse(hex,NumberStyles.HexNumber); return x; }