当前位置: 首页>>代码示例>>C#>>正文


C# SqlTypes.SqlDecimal类代码示例

本文整理汇总了C#中System.Data.SqlTypes.SqlDecimal的典型用法代码示例。如果您正苦于以下问题:C# SqlDecimal类的具体用法?C# SqlDecimal怎么用?C# SqlDecimal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SqlDecimal类属于System.Data.SqlTypes命名空间,在下文中一共展示了SqlDecimal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SqlDecimalBase

 protected SqlDecimalBase(SqlDecimalAny d, byte precision, byte scale)
 {
     if (d != null)
     {
         _d = SqlDecimal.ConvertToPrecScale(d._d, precision, scale);
     }
 }
开发者ID:kellyselden,项目名称:Libraries,代码行数:7,代码来源:SqlDecimalBase.cs

示例2: Create

		public void Create ()
		{
			// SqlDecimal (decimal)
			SqlDecimal Test = new SqlDecimal (30.3098m);
			Assert.AreEqual ((decimal) 30.3098, Test.Value, "#A01");

			try {
				decimal d = Decimal.MaxValue;
				SqlDecimal test = new SqlDecimal (d + 1);
				Assert.Fail ("#A02");
			} catch (OverflowException e) {
				Assert.AreEqual (typeof (OverflowException), e.GetType (), "#A03");
			}

			// SqlDecimal (double)
			Test = new SqlDecimal (10E+10d);
			Assert.AreEqual (100000000000.00000m, Test.Value, "#A05");

			try {
				SqlDecimal test = new SqlDecimal (10E+200d);
				Assert.Fail ("#A06");
			} catch (OverflowException e) {
				Assert.AreEqual (typeof (OverflowException), e.GetType (), "#A07");
			}

			// SqlDecimal (int)
			Test = new SqlDecimal (-1);
			Assert.AreEqual (-1m, Test.Value, "#A08");

			// SqlDecimal (long)
			Test = new SqlDecimal ((long) (-99999));
			Assert.AreEqual (-99999m, Test.Value, "#A09");

			// SqlDecimal (byte, byte, bool. int[]
			Test = new SqlDecimal (10, 3, false, new int [4] { 200, 1, 0, 0 });
			Assert.AreEqual (-4294967.496m, Test.Value, "#A10");

			try {
				Test = new SqlDecimal (100, 100, false,
					new int [4] {Int32.MaxValue,
					Int32.MaxValue, Int32.MaxValue,
					Int32.MaxValue});
				Assert.Fail ("#A11");
			} catch (SqlTypeException) {
			}

			// sqlDecimal (byte, byte, bool, int, int, int, int)
			Test = new SqlDecimal (12, 2, true, 100, 100, 0, 0);
			Assert.AreEqual (4294967297.00m, Test.Value, "#A13");

			try {
				Test = new SqlDecimal (100, 100, false,
					Int32.MaxValue,
					Int32.MaxValue, Int32.MaxValue,
					Int32.MaxValue);
				Assert.Fail ("#A14");
			} catch (SqlTypeException) {
			}
		}
开发者ID:jamescourtney,项目名称:mono,代码行数:59,代码来源:SqlDecimalTest.cs

示例3: GetReady

 public void GetReady() 
 {
 	Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
 	Test1 = new SqlDecimal (6464.6464m);
 	Test2 = new SqlDecimal (10000.00m); 
 	Test3 = new SqlDecimal (10000.00m);                 
 	Test4 = new SqlDecimal (-6m);                 
 }
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:SqlDecimalTest.cs

示例4: GetReady

		public void GetReady ()
		{
            Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en-US";
			Test1 = new SqlDecimal (6464.6464m);
			Test2 = new SqlDecimal (10000.00m);
			Test3 = new SqlDecimal (10000.00m);
			Test4 = new SqlDecimal (-6m);
			Test5 = new SqlDecimal (Decimal.MaxValue);
		}
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:9,代码来源:SqlDecimalTest.cs

示例5: GetReady

		public void GetReady ()
		{
			originalCulture = Thread.CurrentThread.CurrentCulture;
			Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US");
			Test1 = new SqlDecimal (6464.6464m);
			Test2 = new SqlDecimal (10000.00m);
			Test3 = new SqlDecimal (10000.00m);
			Test4 = new SqlDecimal (-6m);
			Test5 = new SqlDecimal (Decimal.MaxValue);
		}
开发者ID:jamescourtney,项目名称:mono,代码行数:10,代码来源:SqlDecimalTest.cs

示例6: SqlDecimalTest

 public SqlDecimalTest()
 {
     _originalCulture = CultureInfo.CurrentCulture; ;
     CultureInfo.CurrentCulture = new CultureInfo("en-US");
     _test1 = new SqlDecimal(6464.6464m);
     _test2 = new SqlDecimal(10000.00m);
     _test3 = new SqlDecimal(10000.00m);
     _test4 = new SqlDecimal(-6m);
     _test5 = new SqlDecimal(decimal.MaxValue);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:SqlDecimalTest.cs

示例7: ToDecimal

        private static Decimal ToDecimal(SqlDecimal value)
        {
            var data = value.Data;
            var scale = value.Scale;

            if (data[3] != 0 || scale > 28)
            {
                var result = decimal.Parse(value.ToString());

                return result;
            }

            return new Decimal(data[0], data[1], data[2], !value.IsPositive, scale);
        }
开发者ID:ciker,项目名称:Shaolinq,代码行数:14,代码来源:SqlServerDecimalDataType.cs

示例8: SqlMoney

 public SqlMoney(decimal value)
 {
     SqlDecimal num2 = new SqlDecimal(value);
     num2.AdjustScale(x_iMoneyScale - num2.Scale, true);
     if ((num2.m_data3 != 0) || (num2.m_data4 != 0))
     {
         throw new OverflowException(SQLResource.ArithOverflowMessage);
     }
     bool isPositive = num2.IsPositive;
     ulong num = num2.m_data1 + (num2.m_data2 << 0x20);
     if ((isPositive && (num > 0x7fffffffffffffffL)) || (!isPositive && (num > 9223372036854775808L)))
     {
         throw new OverflowException(SQLResource.ArithOverflowMessage);
     }
     this.m_value = isPositive ? ((long) num) : ((long) -num);
     this.m_fNotNull = true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:SqlMoney.cs

示例9: SqlMoney

        /// <summary>
        /// Initializes a new instance of the <see cref='SqlMoney'/> class with the value given.
        /// </summary>
        public SqlMoney(decimal value)
        {
            // Since Decimal is a value type, operate directly on value, don't worry about changing it.
            SqlDecimal snum = new SqlDecimal(value);
            snum.AdjustScale(s_iMoneyScale - snum.Scale, true);
            Debug.Assert(snum.Scale == s_iMoneyScale);

            if (snum._data3 != 0 || snum._data4 != 0)
                throw new OverflowException(SQLResource.s_arithOverflowMessage);

            bool fPositive = snum.IsPositive;
            ulong ulValue = snum._data1 + (((ulong)snum._data2) << 32);
            if (fPositive && ulValue > long.MaxValue ||
                !fPositive && ulValue > unchecked((ulong)(long.MinValue)))
                throw new OverflowException(SQLResource.s_arithOverflowMessage);

            _value = fPositive ? (long)ulValue : unchecked(-(long)ulValue);
            _fNotNull = true;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:22,代码来源:SQLMoney.cs

示例10: DecimalDiv

        private static SqlDecimal DecimalDiv(SqlDecimal x, SqlDecimal y)
        {
            ulong lo = 0;
            ulong hi = 0;
            int sc = 0; // scale
            int texp = 0;
            byte prec = 0; // precision
            bool positive = ! (x.positive ^ y.positive);

            prec = x.Precision >= y.Precision ? x.Precision : y.Precision;
            DecimalDivSub(ref x, ref y, ref lo, ref hi, ref texp);

            sc = x.Scale - y.Scale;

            Rescale128(ref lo, ref hi, ref sc, texp, 0, 38, 1);

            uint r = 0;
            while (prec < sc)
            {
                Div128By32(ref hi, ref lo, 10, ref r);
                sc--;
            }

            if (r >= 5)
            {
                lo++;
            }

            while (((hi)*Math.Pow(2, 64) + lo) - Math.Pow(10, prec) > 0)
            {
                prec++;
            }

            while ((prec + sc) > MaxScale)
            {
                Div128By32(ref hi, ref lo, 10, ref r);
                sc--;
                if (r >= 5)
                {
                    lo++;
                }
            }

            var resultLo = (int) lo;
            var resultMi = (int) (lo >> 32);
            var resultMi2 = (int) (hi);
            var resultHi = (int) (hi >> 32);

            return new SqlDecimal(prec, (byte) sc, positive, resultLo,
                                  resultMi, resultMi2,
                                  resultHi);
        }
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:52,代码来源:SqlDecimal.cs

示例11: Sign

 public static SqlInt32 Sign(SqlDecimal n)
 {
     if (n.IsNull)
     {
         return SqlInt32.Null;
     }
     return (n.IsPositive ? 1 : -1);
 }
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:8,代码来源:SqlDecimal.cs

示例12: Power

        public static SqlDecimal Power(SqlDecimal n, double exp)
        {
            if (n.IsNull)
            {
                return Null;
            }

            return new SqlDecimal(Math.Pow(n.ToDouble(), exp));
        }
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:9,代码来源:SqlDecimal.cs

示例13: Multiply

 public static SqlDecimal Multiply(SqlDecimal x, SqlDecimal y)
 {
     return (x*y);
 }
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:4,代码来源:SqlDecimal.cs

示例14: LessThan

 public static SqlBoolean LessThan(SqlDecimal x, SqlDecimal y)
 {
     return (x < y);
 }
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:4,代码来源:SqlDecimal.cs

示例15: GreaterThan

 public static SqlBoolean GreaterThan(SqlDecimal x, SqlDecimal y)
 {
     return (x > y);
 }
开发者ID:tohosnet,项目名称:Mono.Data.Sqlite,代码行数:4,代码来源:SqlDecimal.cs


注:本文中的System.Data.SqlTypes.SqlDecimal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。