zoukankan      html  css  js  c++  java
  • IEE754算法

    C# IEE754算法,仪表设备经常用的数据指令.16进制转10进制,10进制转16进制互转.留作备份,并发给刚入门工控的人.
    算法原理很多人都解释啦,在此就不多说啦,时间有限,上来就干!

      public static class IEE754Method
        {
            public static float HexToFloat(this string hexValue)
            {
                try
                {
                    uint uintValue = Convert.ToUInt32(hexValue, 16);
                    byte[] bytesValue = BitConverter.GetBytes(uintValue);
                    float floatValue = BitConverter.ToSingle(bytesValue, 0);
                    return floatValue;
                }
                catch
                {
                    throw;
                }
            }
    
            public static string FloatToHex(this float floatValue)
            {
                try
                {
                    byte[] bytesValue = BitConverter.GetBytes(floatValue);
                    int intValue = BitConverter.ToInt32(bytesValue, 0);
                    return intValue.ToString("X8");
                }
                catch
                {
                    throw;
                }
            }
        }
  • 相关阅读:

    快排
    排序算法
    运算符
    二叉树
    递归
    队列
    栈(没写完)
    绘制双坐标轴的图形3-不同的plot类型
    绘制双坐标轴的图形2-不同的plot类型
  • 原文地址:https://www.cnblogs.com/mr-meng/p/IEE754.html
Copyright © 2011-2022 走看看