In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use java to calculate the power of 2 to the 64th power". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use java to calculate the power of 2 to the 64th power.
Package com.jtl.common.util / * * @ ProjectName: 20200601 * @ Package: com.jtl.common.util * @ ClassName: StringUtils * @ Author: Administrator * @ Description: ${description} * @ Date: 2020-7-22 0022 9:19 * @ Version: 1.0 * / public class ExStringUtils {/ * * @ param bottom Base, for example, the cubic base of 2 is the index 2, which is the index 3 * @ param var. * @ return * / public static String expString (Integer bottom Integer var) {int I = 0 String str = "1"; while (I
< var) { str = multiString(bottom, str); i++; }return str; }/** * @param bottom 底数 * @param str 指数 * @return */ private static String multiString(Integer bottom, String str) {char[] c = str.toCharArray(); //结果可能和原数组一样长或者比原数组长度长1, 2的3次幂是8,2的4次幂就是16了 char[] result = new char[c.length + 1]; //temp用来表示是否有进位 int temp = 0; for (int i = c.length - 1; i >= 0; iMel -) {/ / traverse from back to front / / 48 is 0 corresponding to the ASCII code int j = (int) c [I]-48; int all = j * bottom; / / Why is it iSig1? , because there may be carry result [I + 1] = ((char) ((all% 10 + temp)% 10 + 48)); temp = (all + temp) / 10;} if (temp! = 0) {/ / finally if carry result [0] = (char) (temp + 48) } / / remove the unwanted 0 return String.valueOf (result) .replaceAll ("\ u0000", "");} public static void main (String [] args) {String string = expString (2,64); System.out.print ("result:" + string);}} so far, I believe you have a better understanding of "how to use java to calculate the power 64 of 2". You might as well do it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.