Java division returns incorrect result

后端 未结 5 1812
不思量自难忘°
不思量自难忘° 2021-01-15 15:28
 public static void main(String[] args) {
        final long a= 24 * 60 * 60 * 1000 * 1000;
        final long b= 24 * 60 * 60 * 1000;

        System.out.println(a/         


        
5条回答
  •  北海茫月
    2021-01-15 16:19

    Plain number in java considered as int. You need to append L to convert to long. Without L a =500654080, which is wrong.

     final long a= 24 * 60 * 60 * 1000 * 1000L;// Append L
    

提交回复
热议问题