endian conversions in C#? 
Author Message
 endian conversions in C#?

Does anyone have a byte swapping routine for big endian <> little endian
conversion of int32s?

I have a nice one in C++ that uses pointers. I'm a newbie to C# and am
somewhat baffled by that lack of pointers for implementing fast little
routines like this.

thanks, Tom



Tue, 25 May 2004 14:22:35 GMT  
 endian conversions in C#?
You don't need to use pointer for endian conversion.

1. You can use HostToNetworkOrder() and NetworkToHostOrder() in the System.Net.IPAddress class.

2. Use some algorithm like:
                 static uint DoReverseEndian(uint x) {
                         return ((x<<24) | ((x & 0xff00)<<8) | ((x & 0xff0000)>>8) | (x>>24));
                 }

Willy.

Quote:

> Does anyone have a byte swapping routine for big endian <> little endian
> conversion of int32s?

> I have a nice one in C++ that uses pointers. I'm a newbie to C# and am
> somewhat baffled by that lack of pointers for implementing fast little
> routines like this.

> thanks, Tom



Tue, 25 May 2004 17:53:11 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. big endian on SUN to little endian on Intel conversion

2. Floats: Big-endian/Little-endian conversion

3. Little-endian to Big-Endian Conversion

4. Help me, conversion from big\little endian

5. Endian conversion for double data type

6. Need an endian conversion function

7. Newbie question - Endian conversion(?)

8. Little/Big Endian Conversion

9. Endian conversion

10. Source utilities for endian conversion

11. big/little endian conversion

12. any alternatives to big/little endian conversion?

 

 
Powered by phpBB® Forum Software