Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ If you are a beginner in javascript, or know it, below you can find articles to

- ECMAScript [en](content/en/ecma-script.md), [pt-br](content/pt-br/ecma-script.md)
- var [en](content/en/var.md), [pt-br](content/pt-br/var.md)
- string [en](content/en/string.md), [pt-br](content/pt-br/string.md)
- String [en](content/en/string.md), [pt-br](content/pt-br/string.md)
- Number [en](content/en/number.md), [pt-br](content/pt-br/number.md)
58 changes: 58 additions & 0 deletions content/en/number.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## Number

Another variable type in Javascript is the type Number.

Is very common in other languages have two or more types to numbers, it is typically a Type integer, and other of type float. sendo normalmente um do tipo inteiro, e outro de tipo flutuante.

```
// Examples of integers:
5
10
22
```

```
// and floats
10.5
0.5
3.3232
102.20
```

However in Javascript, integer numbers or floats and floating numbers are actually the same type of variable, Number. We will see later methods to allow us treat these numbers with the precision we desire.

For now, to create a variable of type Number in Javascript, just assign a value, different of Strings, dont be necessary any special symbol, e.g:

```js
var averageSizeDragon = 68.5;
var amountDragons = 3;
```

We will see more operators in other article, but if you want to advance, below we use some simple operators, to sum, subtract, divide and multiply:

```js
// soma
10 + 10
amountDragons + 1
```

Dont forget to test using the `console.log`.

```js
// subtraction
10 - 5
amountDragons - 2
```

```js
// multiplication
10 * 10
amountDragons * averageSizeDragon
```

```js
// division
32 / 3
32 / 2
amountDragons / averageSizeDragon
```
60 changes: 60 additions & 0 deletions content/pt-br/number.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
## Number

Um outro tipo de varíavel existente em Javascript é o tipo Number.

É comum em outras linguagens termos dois ou mais tipos para números, sendo normalmente um do tipo inteiro, e outro de tipo flutuante.

```js
// exemplos de números inteiros
5
10
22
```



```js
// e de tipos flutuantes
10.5
0.5
3.3232
102.20
```

Porém em Javascript, números inteiros ou flutuantes são na verdade um mesmo tipo de variável, Number. Posteriormente veremos métodos que nos permitirá tratar estes números com a precisão que desejarmos.

Por hora, para criar uma variável do tipo Number em Javascript, simplesmente atribua o valor, diferente de Strings, não é necessário nenhum símbolo especial. Exemplo:

```js
var averageSizeDragon = 68.5;
var amountDragons = 3;
```

Veremos mais operadores em outro artigo, mas se quiser adiantar, abaixo usamos alguns operadores simples, para soma, subtração, divisão e multiplicação:

```js
// soma
10 + 10
amountDragons + 1
```

Não se esqueça de testar usando o `console.log`.

```js
// subtração
10 - 5
amountDragons - 2
```

```js
// multiplicação
10 * 10
amountDragons * averageSizeDragon
```

```js
// divisão
32 / 3
32 / 2
amountDragons / averageSizeDragon
```