本帖最后由 neorobin 于 2012-4-9 19:12 编辑
回复 28# plp626
刚看到你回复的 30 楼, 突然不见了
测试结果
pOffs := (d1st * 10000.0) / 3652425 - p;
The pOffsMin is: -0.004045; the pOffsMax is: 0.001971
The pMin is: 8303; the pMax is: 8496
pOffsMin = -0.004045, pOffsMax + 365*10000 / 3652425 = 1.001307
-0.004045 * 3652425 = -14774.059125
14780 比较恰好的调整误差范围到 [0.000000, 1.005354]:
pOffs := (d1st * 10000.0 + 14780) / 3652425 - p;
The pOffsMin is: 0.000000; the pOffsMax is: 0.006018
The pMin is: 4; the pMax is: 1296
pOffsMin = 0.000000, pOffsMax + 365*10000 / 3652425 = 1.005354
pOffs := (d1st * 10000.0 -7300) / 3652425 - p;
The pOffsMin is: -0.006044; the pOffsMax is: -0.000027
The pMin is: 8303; the pMax is: 2096
pOffsMin = -0.006044, pOffsMax + 365*10000 / 3652425 = 0.999309
Pascal 测试代码- var
- d1st, p, pMin, pMax: longint;
- pOffs, pOffsMin, pOffsMax: real;
- begin
- pOffsMin := 0;
- pOffsMax := -1;
- for p := 1 to 20000 do
- begin
- d1st := 365 * p + p div 4 - p div 100 + p div 400;
- pOffs := (d1st * 10000.0) / 3652425 - p;
- if pOffs < pOffsMin then begin pOffsMin := pOffs; pMin := p; end
- else if pOffs > pOffsMax then begin pOffsMax := pOffs; pMax := p; end;
- WriteLn(p, ' ', d1st, ' ', pOffs: 0: 6);
- end;
- WriteLn('The pOffsMin is: ', pOffsMin: 0: 6, '; the pOffsMax is: ', pOffsMax: 0: 6);
- WriteLn('The pMin is: ', pMin: 0, '; the pMax is: ', pMax: 0);
- WriteLn('pOffsMin = ', pOffsMin: 0: 6, ', pOffsMax + 365*10000 / 3652425 = ', pOffsMax + 365 * 10000 / 3652425: 0: 6);
- Readln;
- end.
复制代码
|