You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The precision loss can cause both increase and decrease of a number. In this particular case the number becomes a tiny bit less, that's why it rounded down.
9
+
La pérdida de precisión puede causar que el número incremente o decremente. En este caso particular el número se vuelve ligeramente menor, por ello es redondeado hacia abajo.
Note that`63.5`has no precision loss at all. That's because the decimal part `0.5`is actually`1/2`. Fractions divided by powers of`2`are exactly represented in the binary system, now we can round it:
27
+
Observa que`63.5` no tiene pérdida de precisión en absoluto. Esto es porque la parte decimal `0.5`es realmente`1/2`. Fracciones divididas por potencias de`2`son representadas exactamente en el sistema binario, ahora podemos redondearlo:
Copy file name to clipboardExpand all lines: 1-js/05-data-types/02-number/3-repeat-until-number/solution.md
+4-5Lines changed: 4 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ function readNumber() {
4
4
let num;
5
5
6
6
do {
7
-
num =prompt("Enter a number please?", 0);
7
+
num =prompt("Ingrese un número por favor:", 0);
8
8
} while ( !isFinite(num) );
9
9
10
10
if (num ===null|| num ==='') returnnull;
@@ -15,9 +15,8 @@ function readNumber() {
15
15
alert(`Read: ${readNumber()}`);
16
16
```
17
17
18
-
The solution is a little bit more intricate that it could be because we need to handle `null`/empty lines.
18
+
La solución es un poco más intrincada de lo que podría ser porque necesitamos manejar `null` y líneas vacías.
19
19
20
-
So we actually accept the input until it is a "regular number". Both `null` (cancel) and empty line also fit that condition, because in numeric form they are `0`.
21
-
22
-
After we stopped, we need to treat `null` and empty line specially (return `null`), because converting them to a number would return `0`.
20
+
Entonces aceptamos entrada de datos hasta que sea un "número regular". También `null` (cancel) y las líneas vacías encajan en esa condición porque un su forma numérica estos son `0`.
23
21
22
+
Una vez detenido el ingreso, necesitamos tratar especialmente los casos `null` y línea vacía (return `null`), porque al convertirlos devolverían `0`.
0 commit comments