示例#1
0
 /// <summary>
 /// Converts the given unsigned rational number to an array of bytes.
 /// Numbers are converted from the platform byte-order to the given byte-order.
 /// </summary>
 public static byte[] GetBytes(MathEx.UFraction32 value, ByteOrder tobyteorder)
 {
     byte[] num  = GetBytes(value.Numerator, ByteOrder.System, tobyteorder);
     byte[] den  = GetBytes(value.Denominator, ByteOrder.System, tobyteorder);
     byte[] data = new byte[8];
     Array.Copy(num, 0, data, 0, 4);
     Array.Copy(den, 0, data, 4, 4);
     return(data);
 }
示例#2
0
 /// <summary>
 /// Returns an array of unsigned rational numbers converted from
 /// the given byte array.
 /// Numbers are converted from the given byte-order to platform byte-order.
 /// </summary>
 public static MathEx.UFraction32[] ToURationalArray(byte[] data, int count, ByteOrder frombyteorder)
 {
     MathEx.UFraction32[] numbers = new MathEx.UFraction32[count];
     for (uint i = 0; i < count; i++)
     {
         byte[] num = new byte[4];
         byte[] den = new byte[4];
         Array.Copy(data, i * 8, num, 0, 4);
         Array.Copy(data, i * 8 + 4, den, 0, 4);
         numbers[i].Set(ToUInt32(num, 0, frombyteorder, ByteOrder.System), ToUInt32(den, 0, frombyteorder, ByteOrder.System));
     }
     return(numbers);
 }