Java Primitive

来源:互联网 发布:mysql character set 编辑:程序博客网 时间:2024/05/02 06:44

Java Primitive

As of the Java Virtual Machine Specification second edition, numeric types, the boolean type (§3.3.4), and the returnAddress type are the three java primitive types supported by JVM.

Most of you may get annoyed, we all know about the primitives of java. That is where from we all started it. 

But, you may not be aware of a primitive called returnAddress. Surprise isn’t it? 

This post serves just to bring that primitive to your notice. It is not part of the language construct / api and is not of direct use to an application programmer. 

But it is good to be aware of the primitive for the sake of completeness.

1) Numeric Types

Numeric types are classified as integral primitive and floating point type primitives
Integral type primitive:

byte –  8-bit signed two’s complement integers: -128 to 127 (-2power7 to 2power7 – 1)
short – 16-bit signed two’s complement integers: -32768 to 32767 (-2power15 to 2power15 – 1)
int – 32-bit signed two’s complement integers
long – 64-bit signed two’s complement integers
char – 16-bit unsigned integers representing Unicode characters (§2.1)

Value ranges from -2power(N-1) to 2power(N-1) – 1 ; where N is the bit size like 8 or 16,…

In the above, two’s complement means, a negative number will be denoted by the two’s complent of its absolute value. 

Most significat digit (MSB) will denote if the number is positive or negative. MSB will be 0 if the number is positive and 1 if it is negative.

Floating-point primitives are float and double

  • positive and negative sign-magnitude numbers
  • positive and negative zeros
  • positive and negative infinities
  • a special Not-a-Number value (used to represent zero/zero kind of numbers).

2) boolean type primitive

encode the truth values true and false. Even booleans are in turn processed using int instructions.

3) returnAddress type primitive

returnAddress types are pointers to the opcodes of JVM instructions like jsr, ret, and jsr_w


0 0
原创粉丝点击