Java – BigIntegerの長さを見つけますか?
Javaでは、BigIntegerをStringオブジェクトに変換し、文字列の長さを取得できます。
JavaExample.java
package com.example;
import java.math.BigInteger;
public class JavaExample {
public static void main(String[] args) {
BigInteger bigInteger = BigInteger.valueOf(100000000000000000L); //18
System.out.println(bigInteger.toString().length());
}
}
出力
18