public IntDecimal Terminate() { IntDecimal sd = new IntDecimal(); sd.i = ret; sd.d = sumQty; return(sd); }
public static IntDecimal Parse(SqlString s) { if (s.IsNull) { return(Null); } // Parse input string to separate out sum and prod. IntDecimal sp = new IntDecimal(); string[] xy = s.Value.Split(",".ToCharArray()); //sp.sum = Int64.Parse(xy[0]); sp.i = SqlInt64.Parse(xy[0]); sp.d = decimal.Parse(xy[1]); // Call ValidatePoint to enforce validation // for string conversions. if (!sp.ValidatePoint()) { throw new ArgumentException("Invalid sum and prod values"); } return(sp); }
/// <summary> /// Gets the <see cref="Decimal"/> number from the binary representation. /// </summary> /// <param name="array">The array that stores the binary representation.</param> /// <param name="startIndex">The starting position within <paramref name="array"/>.</param> /// <returns>The value found.</returns> public static decimal ToDecimal( byte[] array, int startIndex ) { CheckArgs(array, startIndex, count: 16); ConditionalReverse(array, startIndex, count: 16); var converter = new IntDecimal(); converter.Lo = ((int)array[0]) | ((int)array[1] << 8) | ((int)array[2] << 16) | ((int)array[3] << 24); converter.Mid = ((int)array[4]) | ((int)array[5] << 8) | ((int)array[6] << 16) | ((int)array[7] << 24); converter.Hi = ((int)array[8]) | ((int)array[9] << 8) | ((int)array[10] << 16) | ((int)array[11] << 24); converter.Flags = ((int)array[12]) | ((int)array[13] << 8) | ((int)array[14] << 16) | ((int)array[15] << 24); return converter.DecimalValue; }
/// <summary> /// Gets the binary representation of the specified <see cref="Decimal"/> number. /// </summary> /// <param name="value">The value to convert to bytes.</param> /// <param name="array">The array that stores the binary representation.</param> /// <param name="startIndex">The starting position within <paramref name="array"/>.</param> public static void GetBytes( decimal value, byte[] array, int startIndex ) { CheckArgs(array, startIndex, count: 16); var d = new IntDecimal(); d.DecimalValue = value; array[0] = (byte)d.Lo; array[1] = (byte)(d.Lo >> 8); array[2] = (byte)(d.Lo >> 16); array[3] = (byte)(d.Lo >> 24); array[4] = (byte)d.Mid; array[5] = (byte)(d.Mid >> 8); array[6] = (byte)(d.Mid >> 16); array[7] = (byte)(d.Mid >> 24); array[8] = (byte)d.Hi; array[9] = (byte)(d.Hi >> 8); array[10] = (byte)(d.Hi >> 16); array[11] = (byte)(d.Hi >> 24); array[12] = (byte)d.Flags; array[13] = (byte)(d.Flags >> 8); array[14] = (byte)(d.Flags >> 16); array[15] = (byte)(d.Flags >> 24); ConditionalReverse(array, startIndex, count: 16); }