2015-05-19 74 views

回答

0

隱蔽HAX到單精度,步驟如下

    使用X格式提供商
  1. 轉換HAX成字節數組
  2. 二進制轉換成用於所有元素字節陣列
  3. Conevrt小數到字符串
  4. 轉換爲單個

    decimal decValue = 989.99M; 
    string hexValue = decValue.ToString("X"); 
    //Convert to float(24)/Single-precision floating-point format/ IEEE 754-2008/ binary32. 
    
    byte[] raw = new byte[hexValue.Length/2]; 
    for (int i = 0; i < raw.Length; i++) 
    { 
        raw[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16); 
        raw[raw.Length - i - 1] = Convert.ToByte(hex.Substring(i * 2, 2), 16); 
    } 
    
    float f = BitConverter.ToSingle(raw, 0); 
    
相關問題