コード例 #1
0
        private float?GeneratePositiveSingleValue(DbaseField field)
        {
            if (field.Length < DbaseSingle.PositiveValueMinimumLength || !SingleSupportedFieldTypes.Contains(field.FieldType))
            {
                return(null);
            }

            var digits = DbaseIntegerDigits.Min(field.PositiveIntegerDigits, DbaseSingle.MaximumIntegerDigits);
            var number = GeneratePositiveNumber(digits, field.DecimalCount);

            return(Single.Parse(
                       number,
                       NumberStyles.AllowDecimalPoint,
                       new NumberFormatInfo
            {
                NumberDecimalDigits = field.DecimalCount.ToInt32(),
                NumberDecimalSeparator = "."
            }));
        }
コード例 #2
0
        private double?GenerateNegativeDoubleValue(DbaseField field)
        {
            if (field.Length < DbaseDouble.NegativeValueMinimumLength || !DoubleSupportedFieldTypes.Contains(field.FieldType))
            {
                return(null);
            }

            var digits = DbaseIntegerDigits.Min(field.NegativeIntegerDigits, DbaseDouble.MaximumIntegerDigits);
            var number = GenerateNegativeNumber(digits, field.DecimalCount);

            return(Double.Parse(
                       number,
                       NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
                       new NumberFormatInfo
            {
                NumberDecimalDigits = field.DecimalCount.ToInt32(),
                NumberDecimalSeparator = ".",
                NegativeSign = "-"
            }));
        }
コード例 #3
0
        public void MinReturnsExpectedResult(int left, int right, int expected)
        {
            var result = DbaseIntegerDigits.Min(new DbaseIntegerDigits(left), new DbaseIntegerDigits(right));

            Assert.Equal(new DbaseIntegerDigits(expected), result);
        }