08/08/08 17:59:05
>>871
はい、VB6の本の最初に出てくるアルゴリズムだよね。
対象がマイナス値の時に、求める値が「負の無限大へ」か、「値が大きくなる方へ」か。
Function MaxcRound(ByVal tempValue As Double, tempKeta As Long) As Double
'四捨五入する ・・値が大きくなる方へ
Dim tempKekka As Double '移動桁結果
tempKekka = Int(tempValue * 10 ^ tempKeta + 0.5)
MaxcRound = tempKekka / 10 ^ tempKeta
End Function
Function AbscRound(ByVal tempValue As Double, tempKeta As Long) As Double
'四捨五入する ・・負の無限大へ=Excel的 ,JIS Z 8401、規則B
Dim tempKekka As Double '移動桁結果
tempKekka = Int(Abs(tempValue * 10 ^ tempKeta) + 0.5) * Sgn(tempValue)
AbscRound = tempKekka / 10 ^ tempKeta
End Function
AccessのRound関数≠ExcelのRound関数
AccessのRound関数: 最近接偶数への丸め=銀行丸め
JIS Z 8401、規則A