Tuesday, 24 April 2012

Variables in programming

So, I have just started on Eclispe and java programing

First, let me recall all the variables in actionscript 3:
  • int: Used to store a positive or negative whole number.
  • unit:  Used to store any numbers between 0 and (2 to the power of whatever number, but it's still that huge) inclusivesly. Like int, only whole numbers.
  • Number:  Used to store a positive or negative number. This includes decimals (like 1.5)
  • static const: Essentially, a Number variable, except it cannot be changed by programming alone
  • boolean: Used to stored data on true and false.
  • string: Used to store words.
And that's all I can remember. They're the ones I used in as3.

Java retains boolean and int, while having completely different variables:
  • double is equilivent to as3's Numbers
  • short is equilivent to int*
  • float is equilivent to double*
However, for the case of short and float, they can store less range of numbers compared to their equilivents. This is because they use less bits to store less data and thus, choosing these 2 will save space. (More specifically, short and float are 32-bit var while int and double are 64-bit.

The real question, however, is whether negative numbers will work as well.

No comments:

Post a Comment