如何在Java中比较长值

时间:2019-06-27 05:55:20

标签: java

如何在HackerEarth上的Online Test中比较长值范围。     例:1

long x=Long.parseLong(input1[0]);
if( x <1 || x> Math.pow(10,18))
    {
        System.out.println("ERROR");
    }
     System.out.println("NO ERROR");
Input : Input:100000000000000000000
Output: No error
Expected : Error

long x=Long.parseLong(input1[0]);
if( x <1 || x> 100000000000000000000)
    {
        System.out.println("ERROR");
    }
     System.out.println("NO ERROR");
Input : Input:100000000000000000000
Output: error: integer number too large: 1000000000000000000

0 个答案:

没有答案
相关问题