Numerical sets. Types of numbers and application


Numer­ic sets are used to group num­bers that have sim­i­lar char­ac­ter­is­tics. It is one of the basic con­cepts of math­e­mat­ics so it is impor­tant to under­stand what they are and what char­ac­ter­is­tics each has.




What are number sets used for?

Numer­ic sets are used to sep­a­rate num­bers into dif­fer­ent class­es that have sim­i­lar properties. 

We must see this sim­ply as a form of orga­ni­za­tion, in which giv­en any num­ber we say that this num­ber belongs to such a set.

Numerical Sets

The basic numer­i­cal sets are as follows:

  • Nat­ur­al — ℕ
  • Inte­ger — ℤ
  • Ratio­nal — ℚ
  • Real — ℝ
  • Com­plex — ℂ

Each more gen­er­al set encom­pass­es the pre­vi­ous set, i.e. for exam­ple all nat­ur­al num­bers are inte­gers, but not all inte­gers are natural.

Set of Natural Numbers (ℕ)

This set is made up of the num­bers {1,2,3,…} (the sus­pen­sion points indi­cate that the enu­mer­a­tion con­tin­ues indef­i­nite­ly), these num­bers are all pos­i­tive and rep­re­sent inte­ger mag­ni­tudes, i.e. they have no dec­i­mal part.

Set of integer numbers (ℤ)

If to the nat­ur­al num­bers we add the num­ber 0 and the neg­a­tive num­bers with­out dec­i­mal part we obtain the set of inte­gers. {…,-3,-2,-1,0,1,2,3,…}.

With neg­a­tive num­bers we can rep­re­sent sub­trac­tion oper­a­tions, miss­ing mag­ni­tudes, val­ues below the ref­er­ence zero and so on.

Some exam­ples are out­go­ing flows of mon­ey, that is, mon­ey that we pay and sub­tract from what we have; tem­per­a­tures below zero are expressed as neg­a­tive val­ues of degrees Celsius.

Sets of Rational Numbers (ℚ)

The set of ratio­nal num­bers aris­es from mak­ing divi­sions of two whole num­bers. For exam­ple 1 divid­ed 2 is an oper­a­tion that results in a num­ber that is small­er than 1 but larg­er than 0.

These num­bers are used to rep­re­sent non inte­ger mag­ni­tudes, for exam­ple vari­ables of con­tin­u­ous nature such as speed, weight, elec­tric cur­rent; to express frac­tion­al quan­ti­ties such as half a kilo of flour are 0.5 kg of flour. 

Set of Real Numbers (ℝ)

If to the set of ratio­nal num­bers we add the set of irra­tional num­bers we get the set of real numbers.

Irra­tional num­bers arise from per­form­ing cer­tain oper­a­tions and it is not pos­si­ble to express them as the quo­tient between two whole numbers.

An exam­ple of this type of num­bers is the well-known Pi num­ber which is com­posed of infi­nite dec­i­mal digits.

Set of Complex Numbers (ℂ)

If we add imag­i­nary num­bers to the set of real num­bers, we get the set of com­plex num­bers. Any num­ber we choose will be, in gen­er­al terms, a com­plex number.

The imag­i­nary num­ber i is the result of the square root of ‑1.

Com­plex num­bers are com­posed of a real part and an imag­i­nary part and are very use­ful for the study of elec­tri­cal cir­cuits involv­ing capac­i­tive or induc­tive ele­ments. They are also used in Fouri­er trans­form calculations.

Numerical Sets in Videogames

Modeling of game elements

To mod­el the behav­ior of dif­fer­ent ele­ments in our game we will prob­a­bly need to use dif­fer­ent types of numbers. 

For exam­ple a char­ac­ter may have a stan­dard of liv­ing rep­re­sent­ed by hearts. When it is dam­aged it los­es a heart and when it takes a heal­ing potion it recov­ers a heart. In this case the health lev­el is a whole magnitude.

We can also think, for exam­ple, that each heart can be divid­ed into four parts and each blow received takes away a quar­ter of our heart. In addi­tion it could be that a strong ene­my takes away three quar­ters of our heart with each blow. In this case we are think­ing of hearts as ratio­nal mag­ni­tudes and we are going to need dec­i­mal num­bers to rep­re­sent them.

It all depends on how we want our mod­el to be.

Numerical sets in programming

To rep­re­sent the dif­fer­ent types of num­bers we need to build mod­els, we have ele­ments called vari­ables, which are spaces in the mem­o­ry where infor­ma­tion is stored.

Some time ago I made a video about what a vari­able in pro­gram­ming is and also wrote an arti­cle for this page.

Types of numerical variables in C#

The pro­gram­ming lan­guage we use in Uni­ty offers us dif­fer­ent types of variables.


To rep­re­sent inte­ger mag­ni­tudes we have for exam­ple the byte, the short, int and long

Each has its own range of rep­re­sen­ta­tion, for exam­ple the int allows us to rep­re­sent inte­gers that are between ‑2,147,483,648 and 2,147,483,647. The short instead allows us to rep­re­sent num­bers between ‑32,768 and 32,767, which is also a fair­ly large range.

By default we are going to use the int vari­able type to rep­re­sent inte­ger magnitudes.


The float­ing point sys­tem is used to rep­re­sent dec­i­mal val­ues in computation.

We have 32-bit float type vari­ables, 64-bit dou­ble type vari­ables and 128-bit dec­i­mal type vari­ables. Each one has a cer­tain range of rep­re­sen­ta­tion and precision.

In com­pu­ta­tion, infi­nite dig­its can­not be stored, so irra­tional num­bers will be rep­re­sent­ed as ratio­nal num­bers and a trun­ca­tion error will arise.


Com­plex num­bers can be rep­re­sent­ed with two real num­bers, one is the real part and the oth­er is the imag­i­nary part, the lat­ter will be mul­ti­plied by the num­ber i. As expressed in the fol­low­ing equation:

Z = X + i . Y

X and Y being real num­bers and Z being a com­plex number.

We can rep­re­sent com­plex num­bers using two floats with sig­nif­i­cant names for the real and imag­i­nary parts, we can use two-com­po­nent vec­tors, or we can use the Com­plex class of C#.


Numer­ic sets are names we use to clas­si­fy the dif­fer­ent types of num­bers that exist.

Know­ing the dif­fer­ent types of num­bers and their prop­er­ties will help us in build­ing mod­els for our games.

Para imple­men­tar los números en pro­gra­mación con­ta­mos con ele­men­tos lla­ma­dos vari­ables. Exis­ten dis­tin­tos tipos de vari­ables para rep­re­sen­tar números enteros y racionales, cada tipo tiene su pro­pio ran­go de representación.

Scroll to Top
Secured By miniOrange