Integers

=Integers=

An integer is data type which represents a whole number. This means the number cannot have any decimals of any kind, any division that results in a decimal will be rounded down. A normal integer has a range of -2^31 to 2^31-1, however there are other data type that can hold smaller and larger numbers. e.g.
 * Data Type || # of bits || # bytes || range ||
 * byte/char || 8 || 1 || -128 to 127 ||
 * short || 16 || 2 || -2^15 to 2^15-1 ||
 * int || 32 || 4 || -2^31 to 2^31-1 ||
 * long || 64 || 8 || -2^63 to 2^63-1 ||

In C++
Initializing an integer in C++ is pretty strait forward: code format="cpp" main{ int myInteger; myInteger = 5;

long aLong = 155555; short myShort; char aSmallNumber = 5; //you cannot declare a byte in cpp but you can declare a char which is the same size } code

In Java
Initializing an integer in Java is exactly the same. Java also provides classes for all the data structures so you can point to them. Java also provides a BigInteger class that can be as large as you want it to be. code format="java" import java.math.BigInteger;

public class IntDemo{ public static void main(String[] args){ int myInteger; myInteger = 5;

long aLong = 155555; short myShort;

byte aSmallNumber = 5; //these two are the same size char anotherSmallNumber = 5;

BigInteger massiveNumber = new BigInteger("999999999999999999999999999999"); } } code