gpt4 book ai didi

java - 这两个 : BigInteger. valueOf(10000) 和 BigInteger.valueOf(0010000) 有什么区别?

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:45:27 26 4
gpt4 key购买 nike

我在处理一个问题时遇到了这个问题。发生的事情是:

当我们使用它时:BigInteger.valueOf(10000) 它给出的值为 10000

但是

当我们使用此 BigInteger.valueOf(0010000) 时,它给出的值为 4096

两者有什么区别?

最佳答案

0010000 是一个八进制文字。这与 BigInteger 无关 - 它只是 Java 整数文字 (JLS 3.10.1):

System.out.println(10000);   // 10000
System.out.println(0010000); // 4096

来自 JLS:

A decimal numeral is either the single ASCII digit 0, representing the integer zero, or consists of an ASCII digit from 1 to 9 optionally followed by one or more ASCII digits from 0 to 9 interspersed with underscores, representing a positive integer.

...

An octal numeral consists of an ASCII digit 0 followed by one or more of the ASCII digits 0 through 7 interspersed with underscores, and can represent a positive, zero, or negative integer.

关于java - 这两个 : BigInteger. valueOf(10000) 和 BigInteger.valueOf(0010000) 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40212217/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com