/// <summary>
 /// Returns whether a given BigDecimal value fits within the restrictions of the VoltDecimal type.
 /// </summary>
 /// <param name="value">Value to check.</param>
 /// <returns>True if the value either represents 'NULL' or fits within the Volt decimal boundaries.  False otherwise.</returns>
 private static bool IsValidValue(BigDecimal value)
 {
     if ((value == VoltDecimal.NullValue)
         || ((value >= VoltDecimal.MinValue) && (value <= VoltDecimal.MaxValue)))
         return true;
     return false;
 }
 /// <summary>
 /// Checks a value and, in case of validation failure throws an exception.
 /// </summary>
 /// <param name="value">Value to validate.</param>
 private void ValidOrThrow(BigDecimal value)
 {
     if (!IsValidValue(value))
         throw new ArgumentOutOfRangeException(string.Format(Resources.VoltDecimalOutsideOfRange, value));
 }
 /// <summary>
 /// Creates a new decimal from a string value.
 /// </summary>
 /// <param name="num">Value used for initialization.</param>
 public VoltDecimal(string num)
 {
     this.Value = new BigDecimal(num).setScale(FixedScale);
     ValidOrThrow(this.Value);
 }
 /// <summary>
 /// Creates a new decimal from a BigInteger value and optional scale (will be redefined to FixedScale after original initialization).
 /// </summary>
 /// <param name="num">Value used for initialization.</param>
 /// <param name="scale">Scale of the decimal value to create.</param>
 public VoltDecimal(BigInteger num, int scale)
 {
     this.Value = new BigDecimal(num, scale).setScale(FixedScale);
     ValidOrThrow(this.Value);
 }
 /// <summary>
 /// Creates a new decimal from a generic BigDecimal value.
 /// </summary>
 /// <param name="num">Value used for initialization.</param>
 public VoltDecimal(BigDecimal num)
 {
     this.Value = num.setScale(FixedScale);
     ValidOrThrow(this.Value);
 }
 /// <summary>
 /// Creates a new instance of the BigDecimal data type, from the deserialization data.
 /// </summary>
 /// <param name="data">Binary data as provided by the server's response.</param>
 public VoltDecimal(byte[] data)
 {
     this.Value = BigDecimal.FromBytes(data, 12);
 }