当我尝试调用方法expreal时,我得到这个结果:15.999999999999998。结果应该是16。 解决这个问题的正确方法是什么?
class Rational {
constructor(numerator, denominator) {
this.numerator = numerator;
this.denominator = denominator;
}
expreal(base) {
return Math.pow(base, this.numerator / this.denominator);
}
}
let rational = new Rational(4, 3);
console.log(rational.expreal(8));