I want to calculate x power y , and x, y - double . Why does java give me a compilation error? What is the best way to do this?
I am currently using the following method:
x^y // attempt to calculate (x pow y)
Thank.
The easiest way to implement it remains, as always:
Take the logarithm (base 10) x; multiply it by y and take the inverse logarithm (base of 10) of the result to get x pow y.
To just calculate it Math.pow(x,y);, as indicated.
Math.pow(x,y);
Math.pow(x, y);
Read the docsjava.lang.Math .
java.lang.Math
:
Math.pow(2.23, 3.45);
Math.pow(a, b);
See the Math class . It has a static pow function that takes double values as arguments.
Double a = 3.0; Double b = 2.0; assert Math.pow(a, b) == 9.0;
Source: https://habr.com/ru/post/1754952/More articles:relationship between REX and Brew OS? - brewHow to check an anonymous inner class that calls a private method - javaWhere is the account information of the new asp.net mvc web application stored? - c #Как декодировать строку JSON в строку, а не в unicode - jsonDefine multiple variables in one step? - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1754953/which-methods-to-close-a-compiled-query&usg=ALkJrhiY7NE94xsXEvhTkwa3logQCQVH9QVarchar database sql database sql fields - sqlHow do you update / update a web design project on your clients? - javalog4j and java.lang.NoClassDefFoundError: org / apache / log4j / Layout - javaCan I use a variable to indicate the size of an array of struct elements? - c ++All Articles