using System; class DoubleInfo { public long Mantissa; public int Exponent; public bool IsNegative; public override string ToString() { return $"Mantissa: {Mantissa:X8}, Exponent: {Exponent}, " + $"Sign: {(IsNegative ? '-' : '+')}"; } } class Program { static DoubleInfo ExtractInfo(double d) { if (double.IsInfinity(d) || double.IsNaN(d)) return null; var result = new DoubleInfo(); long bits = BitConverter.DoubleToInt64Bits(d); result.IsNegative = bits < 0; result.Exponent = (int) ((bits >> 52) & 0x7ffL); result.Mantissa = bits & 0xfffffffffffffL; if (result.Exponent == 0) // субнормальные числа result.Exponent++; else // нормальные числа, добавляем ведущий бит result.Mantissa = result.Mantissa | (1L << 52); result.Exponent -= 1023; // экспонента сдвинута на 1023 return result; } static void Main(string[] args) { double d1 = 2.1; double d2 = 2; double diff = d1 - d2; Console.WriteLine($"d1 : {ExtractInfo(d1)}"); Console.WriteLine($"d2 : {ExtractInfo(d2)}"); Console.WriteLine($"d1 - d2: {ExtractInfo(diff)}"); } }