Click here to Skip to main content
14,768,146 members
Articles » Web Development » Applications & Tools » Tools with source code
Posted 12 Nov 2012


12 bookmarked

Transform between IEEE, IBM or VAX floating point number formats and bytes expressions

Rate me:
Please Sign up or sign in to vote.
4.00/5 (6 votes)
16 Dec 2012CPOL
This is an alternative for "Transform between IEEE, IBM or VAX floating point number formats and bytes expressions"


Download HERE


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.

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.


John Hou's work is documented here.

Using the code

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#.

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("Press any key to continue...");

Additional methods available off of the Converter class are:

  • ConvertDoublesToBytes - Converts a double value to byte array
  • ConvertSingleToBytes - Converts single floats to byte array

All of the methods will take a Platform enum indicating the source of the origination bytes or doubles. 


2012-11-12  Initial version.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Alan Churchill
Software Developer (Senior) Savian
United States United States
SAS, Microsoft developer/consultant.

Comments and Discussions

GeneralMy vote of 4 Pin
geoatif14-Feb-21 8:29
professionalgeoatif14-Feb-21 8:29 
QuestionIssue converting small float values? Pin
Member 121839758-Jan-16 9:58
MemberMember 121839758-Jan-16 9:58 
AnswerFixed link Pin
Alan Churchill12-Feb-15 11:28
MemberAlan Churchill12-Feb-15 11:28 
GeneralThanks for this ... Pin
Hugh Glover28-Jun-13 1:00
MemberHugh Glover28-Jun-13 1:00 
QuestionCode is GPL Pin
Chase Rayfield22-Jan-13 9:02
MemberChase Rayfield22-Jan-13 9:02 
AnswerRe: Code is GPL Pin
Alan Churchill3-Mar-13 12:46
MemberAlan Churchill3-Mar-13 12:46 
GeneralRe: Code is GPL Pin
Chase Rayfield16-Oct-14 12:13
MemberChase Rayfield16-Oct-14 12:13 
GeneralMy vote of 1 Pin
Paulo Zemek17-Dec-12 10:37
mvaPaulo Zemek17-Dec-12 10:37 
GeneralRe: My vote of 1 Pin
Alan Churchill3-Mar-13 12:48
MemberAlan Churchill3-Mar-13 12:48 
QuestionVAX? Pin
PIEBALDconsult17-Dec-12 4:46
professionalPIEBALDconsult17-Dec-12 4:46 
SuggestionWould be nice with a download link... Pin
kisko11-Dec-12 22:44
Memberkisko11-Dec-12 22:44 
GeneralRe: Would be nice with a download link... Pin
Alan Churchill16-Dec-12 20:58
MemberAlan Churchill16-Dec-12 20:58 
QuestionDownload Link Missing Pin
Tarek K. Mahfouz18-Nov-12 20:43
MemberTarek K. Mahfouz18-Nov-12 20:43 
QuestionDownload link Pin
Ngaima Sandiman12-Nov-12 21:45
MemberNgaima Sandiman12-Nov-12 21:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.