Ejemplo n.º 1
0
        /// <summary>
        /// Returns the value of compressed number in another form.
        /// </summary>
        /// <param name="minValue">The minimum value the number can hold.</param>
        /// <param name="maxValue">The maximum value the number can hold.</param>
        public TSource GetValue(TSourceNumber minValue, TSourceNumber maxValue)
        {
            maxValue = (TSourceNumber)maxValue.FromDouble(maxValue.AsDouble() - minValue.AsDouble());
            var result = NumberCompressor <TDestination, TDestinationNumber> .Decompress <TSource, TSourceNumber>(Value, maxValue);

            return(result.FromDouble(result.AsDouble() + minValue.AsDouble()).Value);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Sets a new value.
 /// </summary>
 /// <param name="value">The value of the number to store.</param>
 /// <param name="minValue">The minimum value the number can hold.</param>
 /// <param name="maxValue">The maximum value the number can hold.</param>
 public void SetValue(TSourceNumber value, TSourceNumber minValue, TSourceNumber maxValue)
 {
     value    = (TSourceNumber)value.FromDouble(value.AsDouble() - minValue.AsDouble());
     maxValue = (TSourceNumber)maxValue.FromDouble(maxValue.AsDouble() - minValue.AsDouble());
     Value    = NumberCompressor <TDestination, TDestinationNumber> .Compress <TSource, TSourceNumber>(value, maxValue);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns the value of compressed number in another form.
 /// </summary>
 /// <param name="maxValue">The maximum value the number can hold.</param>
 public TSource GetValue(TSourceNumber maxValue)
 {
     return(NumberCompressor <TDestination, TDestinationNumber> .Decompress <TSource, TSourceNumber>(Value, maxValue).Value);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets a new value.
 /// </summary>
 /// <param name="value">The value of the number to store.</param>
 /// <param name="maxValue">The maximum value the number can hold.</param>
 public void SetValue(TSourceNumber value, TSourceNumber maxValue)
 {
     Value = NumberCompressor <TDestination, TDestinationNumber> .Compress <TSource, TSourceNumber>(value, maxValue);
 }