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


C# Number.Normalize方法代码示例

本文整理汇总了C#中System.Number.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# Number.Normalize方法的具体用法?C# Number.Normalize怎么用?C# Number.Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Number的用法示例。


在下文中一共展示了Number.Normalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HslColor

 public HslColor(Number hue, Number saturation, Number lightness, Number alpha)
 {
     Hue = (hue.ToNumber()/360d)%1d;
     Saturation = saturation.Normalize(100d)/100d;
     Lightness = lightness.Normalize(100d)/100d;
     Alpha = alpha.Normalize();
 }
开发者ID:nlerikheemskerk,项目名称:cassette,代码行数:7,代码来源:HslColor.cs

示例2: Reduce

		public unsafe void Reduce (Number x)
		{
			int k = mod.length, kp1 = k + 1, km1 = k - 1;

			if (x.length < k)
				return;

			Number q = new Number (x.length - km1 + constant.length);
			Number r = new Number (kp1);
			fixed (uint* pq = q.data, pr = r.data, pm = mod.data, px = x.data, pc = constant.data) {
				Number.Multiply (px + km1, x.length - km1, pc, constant.length, pq);

				x.length = (x.length > kp1 ? kp1 : x.length);
				x.Normalize ();

				uint* xs = pq + kp1, xe = xs + q.length - kp1;
				uint* ys = pm, ye = ys + mod.length;
				uint* zs = pr, ze = zs + kp1;

				for (; xs < xe; xs++, zs++) {
					if (*xs == 0) continue;
					ulong carry = 0;
					uint* zp = zs;
					for (uint* yp = ys; yp < ye && zp < ze; yp++, zp++) {
						carry += ((ulong)*xs) * ((ulong)*yp) + ((ulong)*zp);
						*zp = (uint)carry;
						carry >>= 32;
					}
					if (carry != 0 && zp < ze)
						*zp = (uint)carry;
				}
				r.Normalize ();

				if (r.CompareTo (x) <= 0) {
					x.length = Number.Subtract (px, x.length, pr, r.length, px);
				} else {
					Number val = new Number (kp1 + 1);
					val.data[kp1] = 1;
					fixed (uint* pv = val.data) {
						val.length = Number.Subtract (pv, val.length, pr, r.length, pv);
						x.length = Number.Add (px, x.length, pv, val.length, px);
					}
				}
				x.Normalize ();

				while (x.CompareTo (mod) >= 0) {
					x.length = Number.Subtract (px, x.length, pm, mod.length, px);
				}
			}
		}
开发者ID:kazuki,项目名称:opencrypto.net,代码行数:50,代码来源:Barrett.cs


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