我想知道使用此模式對齊的公式
From 2088 To 2175 = 128
From 2176 To 2263 = 256
From 2264 To 2351 = 384
From 2352 To 2439 = 512
From 2440 To 2527 = 640
From 2528 To 2615 = 768
每個塊88
增加最終結果128
,這樣做的公式是什么?
uj5u.com熱心網友回復:
你有一個線性函式,在浮點情況下你可以通過兩點重建它:
y = (x * 16 - 32000) / 11
如果你想要整數步128, 256, 384...
,你可以通過除以128
y = (x * 16 - 32000) / 11 / 128 * 128
代碼:
static int Compute(int x) => (x - 2000) / 88 * 128;
演示:
var tests = new (int from, int to)[] {
(2088, 2175),
(2176, 2263),
(2264, 2351),
(2352, 2439),
(2440, 2527),
(2528, 2615),
};
string report = string.Join(Environment.NewLine, tests
.Select(test => $"From {test.from} To {test.to} = [{Compute(test.from)} .. {Compute(test.to)}]")
);
Console.Write(report);
輸出:
From 2088 To 2175 = [128 .. 128]
From 2176 To 2263 = [256 .. 256]
From 2264 To 2351 = [384 .. 384]
From 2352 To 2439 = [512 .. 512]
From 2440 To 2527 = [640 .. 640]
From 2528 To 2615 = [768 .. 768]
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/505873.html
上一篇:鏈接桶的最佳組合