【问题标题】:Java- Notation for /variable/Java- /variable/ 的表示法
【发布时间】:2015-07-16 04:39:45
【问题描述】:

在java中写方法的时候,我注意到这两个函数返回的值是一样的。

// Riemann-Siegel theta function using the approximation by the Stirling series
public static double theta (double t) {
return (t/2.0 * StrictMath.log(t/2.0/StrictMath.PI) - t/2.0
    - StrictMath.PI/8.0 + 1.0/48.0/t + 7.0/5760.0/t/t/t);
}

// Riemann-Siegel theta function using the approximation by the Stirling series
public static double theta2 (double t) {
return (t/2.0 * Math.log(t/(2.0*Math.PI)) - t/2.0
    - Math.PI/8.0 + 1.0/(48.0*Math.pow(t, 1)) + 7.0/(5760*Math.pow(t, 3)));
}

什么是

7.0/5760.0/t/t/t

在做什么?为什么和7.0/(5760*t^3)一样?

【问题讨论】:

  • 如果我有8/2/2/2,就像4/2/2,也就是2/2,也就是1。如果我有8/2^3,就像8/8,也就是1(思考笔记^ 不是用于幂的 Java 运算符)。这是一道数学题。

标签: java variables methods notation


【解决方案1】:

表达式 7.0/5760.0/t1/t2/t3 将从 L-R 计算。 喜欢-

r=(7.0/5760.0)
r1=(result/t1)
r2=(r1/t2)
r3=(r2/t3)

r3 是你的最终结果

如果你有像8/2*2*2 这样的表达式,它的计算方式与我之前解释的相同,但在8/2*(2*2) 表达式中,(2*2) 将首先计算,因为 perathesis 的优先级高于/。 在math.pow() 函数的情况下也是如此,因为函数也具有运算符的更高优先级。

【讨论】:

    猜你喜欢
    • 2015-06-21
    • 2012-10-22
    • 1970-01-01
    • 1970-01-01
    • 2018-09-11
    • 1970-01-01
    • 2018-04-16
    • 2023-03-13
    相关资源
    最近更新 更多