AForge.Range.ToIntRange C# (CSharp) Метод

ToIntRange() публичный Метод

Convert the signle precision range to integer range.
If provideInnerRange is set to , then the returned integer range will always fit inside of the current single precision range. If it is set to , then current single precision range will always fit into the returned integer range.
public ToIntRange ( bool provideInnerRange ) : IntRange
provideInnerRange bool Specifies if inner integer range must be returned or outer range.
Результат IntRange
		public IntRange ToIntRange( bool provideInnerRange )
		{
			int iMin, iMax;

			if ( provideInnerRange )
			{
				iMin = (int) Math.Ceiling( min );
				iMax = (int) Math.Floor( max );
			}
			else
			{
				iMin = (int) Math.Floor( min );
				iMax = (int) Math.Ceiling( max );
			}

			return new IntRange( iMin, iMax );
		}

Usage Example

Пример #1
0
        public void ToRangeTest( float fMin, float fMax, int iMin, int iMax, bool innerRange )
        {
            Range range = new Range( fMin, fMax );
            IntRange iRange = range.ToIntRange( innerRange );

            Assert.AreEqual<int>( iMin, iRange.Min );
            Assert.AreEqual<int>( iMax, iRange.Max );
        }