[译]在IEEE,IBM或VAX浮点数格式和字节表达式之间转换
By robot-v1.0
本文链接 https://www.kyfws.com/applications/transform-between-ieee-ibm-or-vax-floating-point-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 3 分钟阅读 - 1497 个词 阅读量 0[译]在IEEE,IBM或VAX浮点数格式和字节表达式之间转换
原文地址:https://www.codeproject.com/Articles/492449/Transform-between-IEEE-IBM-or-VAX-floating-point
原文作者:Alan Churchill
译文由本站 robot-v1.0 翻译
前言
This is an alternative for “Transform between IEEE, IBM or VAX floating point number formats and bytes expressions”
这是" IEEE,IBM或VAX浮点数格式和字节表达式之间的转换"的替代方法
码(Code)
下载(Download) 这里(HERE)
介绍(Introduction)
John Hou的著作< IEEE,IBM和VAX浮点数之间的转换>最初是用C ++编写的.我接受了John的工作,并将其转换为C#4.0.该代码有助于将IBM float转换为IEEE float,反之亦然.它还包括从VAX浮点到IEEE浮点的转换.(John Hou’s work, Transform between IEEE, IBM, and VAX floating point numbers, was originally written in C++. I took John’s work, and converted it to C# 4.0. This code helps with converting IBM floats to IEEE floats and vice-versa. It also includes transformations for VAX floats to IEEE floats.)
这是侯厚John精彩作品的C#版本.有形软件进行了最初的C ++到C#的转换,然后我进行了清理,修复了缺失的区域,然后包装了引擎,以使其更易于与.NET开发人员一起使用.(This is a C# version of John Hou’s wonderful work. Tangible software did the initial C++ to C# conversion, which I then cleaned up, fixed missing areas, and then wrapped the engine to make it easier to work with for .NET developers.)
背景(Background)
约翰`侯的工作记录在这里.(John Hou’s work is documented here.)
使用代码(Using the code)
这里包括的解决方案有一个测试项目,说明了一个简单的IBM float转换.并非代码转换的每个方面都经过测试,因为即时需求是IBM float支持.欢迎其他人从事VAX或IEEE部件的工作.所有代码都在C#中.(The solution included here has a test project illustrating a simple IBM float conversion. Not every aspect of the code conversion was tested since the immediaten eed was IBM float support. Others are welcome to work on the VAX or IEEE parts. All code is in C#.)
主要类库是Converter.可以称为:(The main class library is Converter. It can be called as:)
Converter c =new Converter();
byte[] bytes = new byte[] { 0x00, 0x00, 0x00, 0x80, 0x31, 0x93, 0x60, 0x48 };
double d = c.ConvertBytesToDouble(Platform.IbmFloat, bytes);
Console.WriteLine("Correct return value should be: " + 1620259200);
Console.WriteLine("Return Value: " + d);
Console.WriteLine();
Console.WriteLine("Press any key to continue...");
Console.Read();
Converter类可用的其他方法包括:(Additional methods available off of the Converter class are:)
ConvertDoublesToBytes
-转换一个(- Converts a)double
重视(value to)byte
数组(array)ConvertSingleToBytes
-转换单(- Converts single)float
到(s to)byte
数组(array) 所有方法都需要(All of the methods will take a)Platform
枚举,指示原始字节或双精度字节的来源.(enum indicating the source of the origination bytes or doubles.)
历史(History)
2012-11-12初始版本.(2012-11-12 Initial version.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C C# C++ VS2013 Visual-Studio Dev 新闻 翻译