From cd2f33e653bb8e54f8a20c6115d2190800ba8fe0 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 13 Aug 2010 23:51:06 +0000 Subject: [PATCH] * Added Utils.UInt64ToBytesBig() git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@3422 52acb1d6-8a22-11de-b505-999d5b087335 --- OpenMetaverseTypes/UtilsConversions.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/OpenMetaverseTypes/UtilsConversions.cs b/OpenMetaverseTypes/UtilsConversions.cs index 9b720f78..1a120d8d 100644 --- a/OpenMetaverseTypes/UtilsConversions.cs +++ b/OpenMetaverseTypes/UtilsConversions.cs @@ -509,12 +509,27 @@ namespace OpenMetaverse return bytes; } + public static byte[] UInt64ToBytesBig(ulong value) + { + byte[] bytes = BitConverter.GetBytes(value); + if (BitConverter.IsLittleEndian) + Array.Reverse(bytes); + + return bytes; + } + public static void UInt64ToBytes(ulong value, byte[] dest, int pos) { byte[] bytes = UInt64ToBytes(value); Buffer.BlockCopy(bytes, 0, dest, pos, 8); } + public static void UInt64ToBytesBig(ulong value, byte[] dest, int pos) + { + byte[] bytes = UInt64ToBytesBig(value); + Buffer.BlockCopy(bytes, 0, dest, pos, 8); + } + /// /// Convert a floating point value to four bytes in little endian /// ordering