當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。