INT的最大最小值

目录

C++

Java

Python


看到这个博客被那么多人看,就重新整理了一下,希望能帮助到你。

2019年6月15日。


C++

  • 中有INT_MAX和INT_MIN的宏定义可直接使用。
  • 或者自行定定义
#define INT_MAX 0x7fffffff

#define INT_MIN 0x80000000

INT_MAX = 2147483647

INT_MIN = -2147483648

Java

  • 使用封装类Integer的静态变量 MIN_VALUE 和 MAX_VALUE

  粘出一部分源代码

public final class Integer extends Number implements Comparable {
    /**
     * A constant holding the minimum value an {@code int} can
     * have, -231.
     */
    @Native public static final int   MIN_VALUE = 0x80000000;

    /**
     * A constant holding the maximum value an {@code int} can
     * have, 231-1.
     */
    @Native public static final int   MAX_VALUE = 0x7fffffff;

    /**
     * The {@code Class} instance representing the primitive type
     * {@code int}.
     *
     * @since   JDK1.1
     */
}

Python

  • python就比较厉害了,python的int可以无限大

你可能感兴趣的:(Java,Python,c++/c)