Вопрос по java – Является ли Java int всегда 32-битным?

73

Error: User Rate Limit ExceededintError: User Rate Limit Exceeded

Ваш Ответ

4   ответа
3

Error: User Rate Limit ExceededError: User Rate Limit Exceeded.

Error: User Rate Limit Exceeded

public static void main(String args[]){

    String max_long = "9223372036854775807";
    String min_long = "-9223372036854775808";

    BigInteger b1 = new BigInteger(max_long);
    BigInteger b2 = new BigInteger(min_long);

    BigInteger sum = b1.add(b1);
    BigInteger difference = b2.subtract(b1);
    BigInteger product = b1.multiply(b2);
    BigInteger quotient = b1.divide(b1);

    System.out.println("The sum is: " + sum);
    System.out.println("The difference is: " + difference);
    System.out.println("The product is: " + product);
    System.out.println("The quotient is: " + quotient);

}

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

7

intError: User Rate Limit ExceededlongError: User Rate Limit Exceeded

115

Error: User Rate Limit ExceededError: User Rate Limit Exceeded.

Error: User Rate Limit ExceededError: User Rate Limit Exceeded:

The integral types are byte, short, int, and long, whose values are 8-bit, 16-bit, 32-bit and 64-bit signed two's-complement integers, respectively, and char, whose values are 16-bit unsigned integers representing UTF-16 code units (§3.1).

Error: User Rate Limit ExceededError: User Rate Limit Exceeded:

The values of the integral types are integers in the following ranges:

  • For byte, from -128 to 127, inclusive
  • For short, from -32768 to 32767, inclusive
  • For int, from -2147483648 to 2147483647, inclusive
  • For long, from -9223372036854775808 to 9223372036854775807, inclusive
  • For char, from '\u0000' to '\uffff' inclusive, that is, from 0 to 65535
Error: User Rate Limit Exceeded
4

Error: User Rate Limit ExceededintError: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

  • compareUnsigned(int x, int y)
  • divideUnsigned(int dividend, int divisor)
  • parseUnsignedInt(String s)
  • parseUnsignedInt(String s, int radix)
  • remainderUnsigned(int dividend, int divisor)
  • toUnsignedLong(int x)
  • toUnsignedString(int i)
  • toUnsignedString(int i, int radix)

Error: User Rate Limit Exceeded

public static void main(String[] args) {
    int uint = Integer.parseUnsignedInt("4294967295");
    System.out.println(uint); // -1
    System.out.println(Integer.toUnsignedString(uint)); // 4294967295
}

Похожие вопросы