本文整理汇总了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();
}
示例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);
}
}
}