指定した精度の数値に切り捨て C# public static double ToRoundDown(double dValue, int iDigits) { double dCoef = System.Math.Pow(10, iDigits); return dValue > 0 ? System.Math.Floor (dValue * dCoef) / dCoef: System.Math.Ceiling(dValue * dCoef) / dCoef; } VB Public Function ToRoundDown(dValue As Double, iDigits As Integer) As Double Dim dCoef As Double = System.Math.Pow(10, iDigits) Return IIf(dValue > 0, System.Math.Floor(dValue * dCoef) / dCoef, System.Math.Ceiling(dValue * dCoef) / dCoef) End Function 例: ToRoundDown(99.123456789, 7) //結果:99.1234567 超多機能のアクセス解析が永久無料! コメント: |