Data Types Programming - 09

- Andrés Cruz

En español
Data Types Programming - 09

Data types are simply a mechanism with which we can represent to save values through the variables that we will later see what they are.

So, in most programming languages we have the following types of data, there may be some more or less depending on the programming language of your preference:

Data types or primitives

  • Numbers
  • Integer types: byte, short, int, long.
  • Real types: float and double.
  • Booleans
  • String

Each primitive type has a different range of positive and negative values, except boolean which only has two values: true and false.

Now, which one to select you might ask; the type of data selected for a given program will depend on the range and type of values that are going to be stored in each of them and whether these are integers, real values, text strings, etc.

In the table below, you can see a representation of the size of the primitives above; For example, for an integer we can represent up to this number that we see on the screen in both negatives and positives; Therefore, if you want to represent a number that can be in this range, you can use an int.
On the other hand, for the short ones we can only represent up to 32,768 in its negative or positive part; Therefore, if you want to represent, for example, an ID number in a country where millions live, you would have to use an int instead of a short, but if you want to represent, for example, the number of tomatoes that a person has in their refrigerator, I will most likely reach you with a pair of shorts; and so on for the rest of the cases.

Andrés Cruz

Desarrollo con Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz en Udemy

Acepto recibir anuncios de interes sobre este Blog.