Post: Little Endian and Big Endian [C#]
03-13-2013, 11:08 PM #1
Sonoro
I like anteaters
(adsbygoogle = window.adsbygoogle || []).push({});
Big-endian and little-endian are two different methods used by computers to store data in memory larger than the bytes (eg, word, dword, QWORD)

A Big Endian or Little endian array is 4 bytes long.


Difference Between Little Endian and Big Endian

The only difference between them is that the bytes order is reversed for big endian.



Using Little Endian and Big Endian in our C# Project

The code to convert an Integer or a decimal into a endian array is the following:

     decimal mydecimal = 1023;
byte[] Little_Endian = BitConverter.GetBytes(Convert.ToInt32(mydecimal.ToString()));



This is what you have to do to get a little endian array. If you are willing to get a big endian array, just add this to the code:

     Array.Reverse(Little_Endian);



The tutorial is ended here, hope you've learned something off it and see you with the next one. :nerd:

The following 3 users say thank you to Sonoro for this useful post:

BadChoicesZ, Notorious, Pichu

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo