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