- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Follow-Up available: There's a follow-up with further details, see Convert MBF to IEEE.
Option Strict
兼容的)(随意将其转换为 C# 并在其中进行编辑):
''' <summary>Converts a MBF Single to an IEEE Single</summary>
''' <param name="src">The MBF Single value</param>
''' <returns>The converted IEEE Single value</returns>
''' <remarks>Here can find some further information about this topic: http://en.wikipedia.org/wiki/Microsoft_Binary_Format http://support.microsoft.com/kb/140520</remarks>
Public Shared Function MTIS(ByVal src As Single) As Single
Return MTIS(BitConverter.GetBytes(src), 0)
End Function
''' <summary>Converts a MBF Single to an IEEE Single</summary>
''' <param name="src">The source array</param>
''' <param name="startIndex">The start index at which the Single starts</param>
''' <returns>The converted IEEE Single value</returns>
''' <remarks>Here can find some further information about this topic: http://en.wikipedia.org/wiki/Microsoft_Binary_Format http://support.microsoft.com/kb/140520</remarks>
Public Shared Function MTIS(ByVal src() As Byte, ByVal startIndex As Integer) As Single
Dim mbf(3) As Byte
Dim ieee(3) As Byte
Array.Copy(src, startIndex, mbf, 0, 4)
If mbf(3) <> 0 Then
Dim sign As Byte = mbf(2) And ToByte(&H80)
Dim exp As Byte = mbf(3) - ToByte(2) ' -1-128-127 '
ieee(3) = ieee(3) Or sign
ieee(3) = ieee(3) Or exp >> 1
ieee(2) = ieee(2) Or exp << 7
ieee(2) = ieee(2) Or mbf(2) And ToByte(&H7F)
ieee(1) = mbf(1)
ieee(0) = mbf(0)
End If
Return BitConverter.ToSingle(ieee, 0)
End Function
''' <summary>Converts a MBF Double to a IEEE Double</summary>
''' <param name="src">The MBF Double value</param>
''' <returns>The converted IEEE Double value</returns>
''' <remarks>Here can find some further information about this topic: http://en.wikipedia.org/wiki/Microsoft_Binary_Format http://support.microsoft.com/kb/140520</remarks>
Public Shared Function MTID(ByVal src As Double) As Double
Return MTID(BitConverter.GetBytes(src), 0)
End Function
''' <summary>Converts a MBF Double to a IEEE Double</summary>
''' <param name="src">The source array</param>
''' <param name="startIndex">The start index at which the Double starts</param>
''' <returns>The converted IEEE Double value</returns>
''' <remarks>Here can find some further information about this topic: http://en.wikipedia.org/wiki/Microsoft_Binary_Format http://support.microsoft.com/kb/140520</remarks>
Public Shared Function MTID(ByVal src() As Byte, ByVal startIndex As Integer) As Double
Dim mbf(7) As Byte
Dim ieee(7) As Byte
Array.Copy(src, startIndex, mbf, 0, 8)
If mbf(7) <> 0 Then
Dim sign As Byte = mbf(6) And ToByte(&H80)
Dim exp As Int16 = mbf(7) - 128S - 1S + 1023S
ieee(7) = ieee(7) Or sign
ieee(7) = ieee(7) Or ToByte(exp >> 4 And &HFF)
ieee(6) = ieee(6) Or ToByte(exp << 4 And &HFF)
For i As Integer = 6 To 1 Step -1
mbf(i) <<= 1
mbf(i) = mbf(i) Or mbf(i - 1) >> 7
Next
mbf(0) <<= 1
For i As Integer = 6 To 1 Step -1
ieee(i) = ieee(i) Or mbf(i) >> 4
ieee(i - 1) = ieee(i - 1) Or mbf(i) << 4
Next
ieee(0) = ieee(0) Or mbf(0) >> 4
End If
Return BitConverter.ToDouble(ieee, 0)
End Function
最佳答案
在 this Wiki 页面上有几个不同的代码示例的链接,用于在 C、C++ 和 Python 中执行此操作。
希望其中一种或多种语言可以相对容易地转换为适合您的某种语言。
关于c# - 将 MBF Single 和 Double 转换为 IEEE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2973913/
除非 IEEE 754 是 NaN、+-0.0 或 +-Infinity,否则自除是否保证结果正好是 1.0? 同样,减去本身是否保证总是导致 +-0.0? 最佳答案 IEEE 754-2008 4.
我已经阅读了一些文本和线程,展示了如何从十进制转换为 IEEE 754,但我仍然对如何在不扩展小数(以科学计数法表示)的情况下转换数字感到困惑 我特别使用的数字是9.07 * 10^23,但任何数字都
为什么 float 中的指数要置换 127? 那么,真正的问题是:与 2 的补码相比,这种表示法有什么优势? 最佳答案 由于存储的指数是无符号的,因此可以使用整数指令来比较浮点值。为了比较(不是补码)
我一直在使用 Mendeley 的 Microsoft Word 插件轻松引用我的 Mendeley 桌面图书馆中的论文。 但是,我注意到 IEEE 格式的引用书目/引文在引用 session 记录和
我花了一周的时间研究这个主题,发现没有语言能够正确满足 IEEE 754 规范。 甚至 GCC 也不尊重相关的 C99 部分(它忽略了 FENV_ACCESS 编译指示,并且我被告知我的工作示例纯粹是
有很多 IEEE 标准。几乎所有语言都保证实现 IEEE 754 二进制 float 。 最佳答案 我认为这只是流水号,就像 IRC 有 RFC1459 关于ieee-754 - IEEE 754 f
我们在类里面有一个作业,要使用 c 从十进制转换为单精度,但我完全迷失了。 这是作业: The last part of this lab involves coding a short c algo
我使用的是在 SoftFloat 库中实现的半 float (阅读:100% IEEE 754 兼容),为了完整起见,我希望为我的代码提供与 float.h> 用于 float、double 和 lo
我很难理解IEEE 754舍入约定: 四舍五入为正无穷大 四舍五入为负无穷大 无偏到最接近的偶数 如果我在二进制点的右边有一个由9位组成的二进制数,并且我需要使用最右边的3位来确定舍入该怎么办? 这是
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 4年前关闭。 Improve this questi
我创建了以下程序来查找 float 的位模式。但我的计算结果有所不同: #include int main(void){ float f = 1.234; char *ch;
我在 18 位软核处理器目标上有一个 gcc 交叉编译器定义了以下数据类型:18 位整数、36 位长整型和 36 位 float (单精度)。现在我的重点是浮点运算。由于宽度是非标准(36位),我有以
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 8 年前。 Improve th
Analog Devices 的 BFF-533 处理器不提供原生浮点支持,但提供浮点仿真。 使用 IDE VisualDSP++,用户可以在高性能浮点和严格的 IEEE 合规性之间进行选择。 据我了
我在没有浮点单元的处理器上工作,所以我必须为用户界面使用固定或自定义浮点类型。 对于这三种类型,say a multiply 的性能如何: IEEE float (32) 具有 16 位有符号值和有符
我对浮点数的工作原理有很好的理解,但我想知 Prop 体的指数和尾数大小是如何决定的。它们在某些方面是最优的吗?如何测量浮点表示的最优性(我假设有几种方法)?我想这些问题在官方标准中得到了解决,但我无
任何人都建议使用良好的压缩算法,该算法可与 double 浮点值一起很好地工作?我们发现,对于浮点值的二进制表示,使用常见的压缩程序(例如Zip,RAR,7-Zip等)会导致非常差的压缩率。 我们需要
我正在尝试将 0.0000211 转换为二进制。目前我的理解是这样的: E = -偏差 + 1。偏差 = 15,E = -14 符号位和指数 = 0。 所以我有: 0 00000 ?????????
我试图找出 ieee 754 中存在多少个不同的整数。我得到的数字是 1778384895,但我找不到任何资源来检查自己。预先非常感谢。 最佳答案 我将假设单精度 float 。 我们得到了零,虽然可
在运行 32 位 GCC 7.3.0 的特定在线判断中,这个: #include volatile float three = 3.0f, seven = 7.0f; int main() {
我是一名优秀的程序员,十分优秀!