四舍六入计算函数公式(Calculate function formula from four to six).docVIP

  • 24
  • 0
  • 约1.01万字
  • 约 15页
  • 2017-10-05 发布于河南
  • 举报

四舍六入计算函数公式(Calculate function formula from four to six).doc

四舍六入计算函数公式(Calculate function formula from four to six)

四舍六入计算函数公式(Calculate function formula from four to six) Four homes five into, odd into my house * * * * * dlys1019 * * * date: 2004.11.10 * * * entrance parameter: * * * X1: the number of rounds needed * * * X2: number of digits reserved * * * FUNCTION ROUNDX PARA, X1, X2 NAAA=INT (x1*10^ (x2+1)) NBBB=INT (x1*10^x2) DO case CASE, VAL (RIGHT (STR (nAAA), 1)) 5,.Or., VAL (RIGHT (STR (nAAA), 1)) 5 RETURN ROUND (x1, x2) CASE VAL (RIGHT (STR (nAAA), 1)) =5 IF MOD (nBBB, 2) =1 RETURN (nBBB+1) / (10^x2) ELSE RETURN nBBB/ (10^x2) ENDIF ENDCASE * for example: round (123.455,2) =123.46 * * * roundx (123.465,2) =123.46 * * VB learning --- odd even even function Measurement procedures must be used to define their own functions, in the measurement of data processing results are required to use odd even even principle to deal with the results. Public, Function, NNN (ByVal, NM, As, Double, ByVal, BB, As, Integer) As Double Rem * * * odd even input function Rem * * * NM is a variable that requires a singular entry, and BB is the multiple after the decimal point that the variable needs to retain in the NM. At most 10 decimal places are allowed Dim BNM As Double Dim C As Integer Dim J As Integer Dim K As Integer Dim I As Double C = Sgn (NM) * * sign function BNM = Abs (NM) * * absolute value function I = (BNM * 10 ^ (BB + 1) + 10 ^ (-11) - 10 * Fix (BNM * 10 ^ BB + 10 ^ (-11))) I = (Fix (I * 10 ^ 10)) / 10 ^ 10 J = Fix (BNM * BB ^ 10 + 10 ^ (-11) Fix (BNM) - 10 * * 10 ^ (BB - 1) + 10 ^ (-11)) * * parity If I 5 Then K = 1 ElseIf I 5 Then K = 0 ElseIf (I = 5, And, j = 2 * Fix (J / 2)) Then K = 0 Else K = 1 End If NNN = C * Fix (BNM * 10 ^ BB + k) / 10 ^ BB End Function For reference..... Abstract: Excel is very familiar with the application software, and its use is very convenient. Especially its powerful functions, has brought great convenience for us, but sometimes we to achieve a specified function, may use several functions or the use of nested functions, such application, is not

文档评论(0)

1亿VIP精品文档

相关文档