Skip to content

Commit 1fe65dd

Browse files
committed
Merge branch 'sync/php-feedback-171-float-terminology'
2 parents 79c09b2 + 5786b16 commit 1fe65dd

12 files changed

Lines changed: 32 additions & 29 deletions

File tree

modules/20-arithmetics/43-float/en/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
In mathematics there are different types of numbers. For example:
22

33
- Natural numbers: positive integers: 1, 2, 3, and so on.
4-
- Rational numbers: fractional numbers that can be represented as a division, for example: 0.5, 1.75, 3.14.
4+
- Fractional numbers: numbers with a fractional part, for example: 0.5, 1.75, 3.14.
55

66
From the point of view of mathematics, everything is simple. But from the computer's point of view, there is a real chasm between these types of numbers. Try to solve mentally: what is `0.2` + `0.1`? Obviously, `0.3`. PHP will show the same when printing:
77

@@ -32,7 +32,7 @@ Check: 0.1 + 0.2 - 0.3 → 5.5511151231258E-17 (not 0)
3232

3333
This behavior is typical for Python, JavaScript, and most other programming languages.
3434

35-
The reason lies in how computers work. A computer operates with limited memory, while rational numbers are infinitely precise. Infinitely many other numbers can fit between 0.1 and 0.2. But a computer cannot store infinity. It approximates the number, trying to fit it into the available number of bits.
35+
The reason lies in how computers work. A computer operates with limited memory, while there are infinitely many fractional numbers: as many as you like fit between 0.1 and 0.2. A computer cannot store infinity, so it approximates the number, trying to fit it into the available number of bits.
3636

3737
Such approximate values are called floating point numbers. Their storage and calculations follow strict rules described in a special standard, IEEE 754, which most programming languages rely on.
3838

modules/20-arithmetics/43-float/en/data.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ tips:
55
[What every computer scientist should know about floating-point
66
arithmetic](https://www.validlab.com/goldberg/paper.pdf)
77
definitions:
8-
- name: Rational number
8+
- name: Floating point number
99
description: |
10-
a number that can be represented as a common fraction.
10+
an approximate representation of a fractional number in computer memory,
11+
defined by the IEEE 754 standard.

modules/20-arithmetics/43-float/es/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
En matemáticas hay diferentes tipos de números. Por ejemplo:
22

33
- Naturales: números enteros positivos: 1, 2, 3, etc.
4-
- Racionales: números fraccionarios que se pueden representar como una división, por ejemplo: 0.5, 1.75, 3.14.
4+
- Fraccionarios: números con parte decimal, por ejemplo: 0.5, 1.75, 3.14.
55

66
Desde el punto de vista de las matemáticas, todo es simple. Pero desde el punto de vista de la computadora, entre estos tipos de números hay un verdadero abismo. Intenta resolver mentalmente: ¿cuánto es `0.2` + `0.1`? Obviamente, `0.3`. PHP mostrará lo mismo al imprimir:
77

@@ -32,7 +32,7 @@ Comprobación: 0.1 + 0.2 - 0.3 → 5.5511151231258E-17 (y no 0)
3232

3333
Este comportamiento es típico de Python, JavaScript y la mayoría de los demás lenguajes de programación.
3434

35-
La razón está en el funcionamiento de la computadora. Una computadora trabaja con memoria limitada, mientras que los números racionales son infinitamente precisos. Entre 0.1 y 0.2 se pueden colocar infinitos números. Pero la computadora no puede almacenar el infinito. Aproxima el número, tratando de ajustarlo a la cantidad de bits disponible.
35+
La razón está en el funcionamiento de la computadora. Una computadora trabaja con memoria limitada, mientras que los números fraccionarios son infinitos: entre 0.1 y 0.2 se pueden colocar cuantos se quiera. La computadora no puede almacenar el infinito, así que aproxima el número, tratando de ajustarlo a la cantidad de bits disponible.
3636

3737
Estos valores aproximados se llaman números de punto flotante (floating point numbers). Su almacenamiento y los cálculos con ellos siguen reglas estrictas descritas en un estándar especial, IEEE 754, en el que se basan la mayoría de los lenguajes de programación.
3838

modules/20-arithmetics/43-float/es/data.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ tips:
55
[Lo que todo informático debe saber sobre la aritmética de punto
66
flotante](https://www.validlab.com/goldberg/paper.pdf)
77
definitions:
8-
- name: Número racional
8+
- name: Número de punto flotante
99
description: |
10-
un número que se puede representar como una fracción común.
10+
representación aproximada de un número fraccionario en la memoria de la
11+
computadora, definida por el estándar IEEE 754.

modules/20-arithmetics/43-float/ru/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
В математике есть разные типы чисел. Например:
22

33
- Натуральные: целые положительные числа: 1, 2, 3 и т.д.
4-
- Рациональные: дробные числа, которые можно представить в виде деления, например: 0.5, 1.75, 3.14.
4+
- Дробные: числа с дробной частью, например: 0.5, 1.75, 3.14.
55

66
С точки зрения математики все просто. Но с точки зрения компьютера между этими типами чисел лежит настоящая пропасть. Попробуйте мысленно решить: сколько будет `0.2` + `0.1`? Очевидно, `0.3`. PHP при выводе покажет то же самое:
77

@@ -32,7 +32,7 @@ print_r(0.1 + 0.2 - 0.3); // => 5.5511151231258E-17
3232

3333
Такое поведение характерно для Python, JavaScript и большинства других языков программирования.
3434

35-
Причина в устройстве компьютера. Компьютер работает с ограниченной памятью, тогда как рациональные числа бесконечно точны. Между 0.1 и 0.2 можно поместить бесконечно много других чисел. Но компьютер не может хранить бесконечность. Он приближает число, стараясь уместить его в доступное количество бит.
35+
Причина в устройстве компьютера. Компьютер работает с ограниченной памятью, а дробных чисел бесконечно много: между 0.1 и 0.2 можно поместить сколько угодно других. Хранить бесконечность компьютер не может, поэтому он приближает число, стараясь уместить его в доступное количество бит.
3636

3737
Такие приближенные значения называются числами с плавающей точкой (floating point numbers). Хранение и вычисления с ними подчиняются строгим правилам, описанным в специальном стандарте IEEE 754, на который ориентируются большинство языков программирования.
3838

modules/20-arithmetics/43-float/ru/data.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ tips:
55
[Что нужно знать про арифметику с плавающей
66
запятой](https://habr.com/ru/articles/112953/)
77
definitions:
8-
- name: Рациональное число
8+
- name: Число с плавающей точкой
99
description: |
10-
число, которое можно представить в виде обыкновенной дроби.
10+
приближенное представление дробного числа в памяти компьютера, устроенное
11+
по стандарту IEEE 754.

modules/33-data-types/40-primitive-data-types/en/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ For example:
44

55
- "Hello, World!" is a string (`string`)
66
- 7, -198, 0 are integers (`int`)
7-
- 3.14, -0.01, 1.0 are rational numbers (`float`)
7+
- 3.14, -0.01, 1.0 are floating point numbers (`float`)
88

99
## What is a data type?
1010

@@ -50,12 +50,12 @@ On the screen the result looks the same, but inside the program these are comple
5050

5151
The number `5` and the string `'5'` are different values, and operations with them work differently. That said, when types don't match, PHP often tries to convert one type into another on its own. How convenient this is and what makes it dangerous we'll look at a bit later in this module.
5252

53-
## Integers and rational numbers
53+
## Integers and fractional numbers
5454

5555
PHP distinguishes between two kinds of numbers:
5656

5757
- `int` denotes integers: -3, 0, 7, 100000
58-
- `float` denotes real (rational) numbers: 1.0, -3.14, 2.718
58+
- `float` denotes fractional numbers, also called floating point numbers: 1.0, -3.14, 2.718
5959

6060
This division is due to the peculiarities of how computers are built — we talked about this in the lesson about floating-point numbers.
6161

@@ -84,7 +84,7 @@ Types such as:
8484

8585
- string,
8686
- int (integer),
87-
- float (rational number)
87+
- float (floating point number)
8888

8989
are called primitive: they are built right into the PHP language itself.
9090

modules/33-data-types/40-primitive-data-types/en/data.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ definitions:
99
- name: Data type
1010
description: >-
1111
a set of data in code (a kind of information). A type defines what you can
12-
do with the elements of a particular set. For example, integers, rational
13-
numbers, and strings are different data types.
12+
do with the elements of a particular set. For example, integers,
13+
fractional numbers, and strings are different data types.
1414
- name: Primitive data types
1515
description: simple types built into the programming language itself.
1616
- name: String (string)

modules/33-data-types/40-primitive-data-types/es/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Por ejemplo:
44

55
- "Hello, World!" es una cadena de texto (`string`)
66
- 7, -198, 0 son números enteros (`int`)
7-
- 3.14, -0.01, 1.0 son números racionales (`float`)
7+
- 3.14, -0.01, 1.0 son números de punto flotante (`float`)
88

99
## ¿Qué es un tipo de dato?
1010

@@ -50,12 +50,12 @@ En la pantalla el resultado se ve igual, pero dentro del programa son cosas comp
5050

5151
El número `5` y la cadena `'5'` son valores diferentes, y las operaciones con ellos funcionan de forma distinta. Eso sí, cuando los tipos no coinciden, PHP a menudo intenta convertir un tipo en otro por sí mismo. Qué tan cómodo es esto y por qué es peligroso lo veremos un poco más adelante en este módulo.
5252

53-
## Números enteros y racionales
53+
## Números enteros y fraccionarios
5454

5555
PHP distingue dos clases de números:
5656

5757
- `int` designa los números enteros: -3, 0, 7, 100000
58-
- `float` designa los números reales (racionales): 1.0, -3.14, 2.718
58+
- `float` designa los números fraccionarios, también llamados números de punto flotante: 1.0, -3.14, 2.718
5959

6060
Esta separación está relacionada con las particularidades de cómo están construidos los ordenadores — hablamos de ello en la lección sobre los números de punto flotante.
6161

@@ -84,7 +84,7 @@ Los tipos como:
8484

8585
- string (cadena de texto),
8686
- int (número entero),
87-
- float (número racional)
87+
- float (número de punto flotante)
8888

8989
se llaman primitivos: están incorporados directamente en el propio lenguaje PHP.
9090

modules/33-data-types/40-primitive-data-types/es/data.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ definitions:
1010
description: >-
1111
conjunto de datos en el código (tipo de información). El tipo determina
1212
qué se puede hacer con los elementos de un conjunto específico. Por
13-
ejemplo, los números enteros, los números racionales, las cadenas de texto
14-
son diferentes tipos de datos.
13+
ejemplo, los números enteros, los números fraccionarios, las cadenas de
14+
texto son diferentes tipos de datos.
1515
- name: Tipos de datos primitivos
1616
description: tipos simples incorporados en el propio lenguaje de programación.
1717
- name: Cadena de texto (string)

0 commit comments

Comments
 (0)