Skip to content

Commit 536e695

Browse files
committed
1.05.02 (number) つづく
1 parent cb20644 commit 536e695

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

1-js/05-data-types/02-number/article.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,33 +104,33 @@ Penggunaan umumnya ialah:
104104
alert( 123456..toString(36) ); // 2n9c
105105
```
106106

107-
```warn header="Two dots to call a method"
108-
Please note that two dots in `123456..toString(36)` is not a typo. If we want to call a method directly on a number, like `toString` in the example above, then we need to place two dots `..` after it.
107+
```warn header="Dua dot untuk memanggil metode"
108+
Tolong ingat bahwa dua dot di `123456..toString(36)` bukan typo. Jika kita mau memanggil langsung metode pada angka, seperti `toString` di contoh di atas, maka kita harus menaruh dua dot `..` setelahnya.
109109
110-
If we placed a single dot: `123456.toString(36)`, then there would be an error, because JavaScript syntax implies the decimal part after the first dot. And if we place one more dot, then JavaScript knows that the decimal part is empty and now goes the method.
110+
Jika kita menaruh dot tunggal: `123456.toString(36)`, maka akan ada galat, karena syntax JavaScript berimplikasi bahwa bagian desimal setelah dot pertama. Dan jika kita menaruh satu dot lagi, maka JavaScript tahu bahwa bagian desimal kosong dan sekarang pergi ke metode.
111111
112-
Also could write `(123456).toString(36)`.
112+
Juga bisa menulis `(123456).toString(36)`.
113113
```
114114

115-
## Rounding
115+
## Pembulatan
116116

117-
One of the most used operations when working with numbers is rounding.
117+
Satu dari operasi paling banyak dipakai saat bekerja dengan angka ialah pembulatan.
118118

119-
There are several built-in functions for rounding:
119+
Ada beberapa fungsi built-in untuk pembulatan:
120120

121121
`Math.floor`
122-
: Rounds down: `3.1` becomes `3`, and `-1.1` becomes `-2`.
122+
: Membulat ke bawah: `3.1` menjadi `3`, dan `-1.1` menjadi `-2`.
123123

124124
`Math.ceil`
125-
: Rounds up: `3.1` becomes `4`, and `-1.1` becomes `-1`.
125+
: Membulat ke atas: `3.1` menjadi `4`, dan `-1.1` menjadi `-1`.
126126

127127
`Math.round`
128-
: Rounds to the nearest integer: `3.1` becomes `3`, `3.6` becomes `4` and `-1.1` becomes `-1`.
128+
: Membulat to the nearest integer: `3.1` becomes `3`, `3.6` becomes `4` and `-1.1` becomes `-1`.
129129

130130
`Math.trunc` (not supported by Internet Explorer)
131131
: Removes anything after the decimal point without rounding: `3.1` becomes `3`, `-1.1` becomes `-1`.
132132

133-
Here's the table to summarize the differences between them:
133+
Ini tabel untuk meringkas perbedaan di antara mereka:
134134

135135
| | `Math.floor` | `Math.ceil` | `Math.round` | `Math.trunc` |
136136
|---|---------|--------|---------|---------|
@@ -140,43 +140,43 @@ Here's the table to summarize the differences between them:
140140
|`-1.6`| `-2` | `-1` | `-2` | `-1` |
141141

142142

143-
These functions cover all of the possible ways to deal with the decimal part of a number. But what if we'd like to round the number to `n-th` digit after the decimal?
143+
Fungsi ini membahas semua cara yang mungkin untuk berhadapan dengan bagian desimal dari angka. Tapi bagaimana jika kita mau membulatkan angka ke digit `ke-n` setelah desimal?
144144

145-
For instance, we have `1.2345` and want to round it to 2 digits, getting only `1.23`.
145+
Misalnya, kita punya `1.2345` dan mau membulatkan ke 2 digit, memperoleh `1.23`.
146146

147-
There are two ways to do so:
147+
Ada dua cara melakukannya:
148148

149-
1. Multiply-and-divide.
149+
1. Kali-dan-bagi.
150150

151-
For example, to round the number to the 2nd digit after the decimal, we can multiply the number by `100`, call the rounding function and then divide it back.
151+
Misalnya, untuk membulatkan angka ke digit kedua setelah desimal, kita bisa mengalikan angkanya dengan `100`, panggil fungsi pembulatan lalu membagi itu kembali.
152152
```js run
153153
let num = 1.23456;
154154
155155
alert( Math.floor(num * 100) / 100 ); // 1.23456 -> 123.456 -> 123 -> 1.23
156156
```
157157

158-
2. The method [toFixed(n)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) rounds the number to `n` digits after the point and returns a string representation of the result.
158+
2. Metode [toFixed(n)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) Membulatkan ke digit `n` setelah poin itu dan mengembalikan representasi string dari hasilnya.
159159

160160
```js run
161161
let num = 12.34;
162162
alert( num.toFixed(1) ); // "12.3"
163163
```
164164

165-
This rounds up or down to the nearest value, similar to `Math.round`:
165+
Ini membulatkan ke atas atau ke bawah ke nilai terdekat, serupa dengan `Math.round`:
166166

167167
```js run
168168
let num = 12.36;
169169
alert( num.toFixed(1) ); // "12.4"
170170
```
171171

172-
Please note that result of `toFixed` is a string. If the decimal part is shorter than required, zeroes are appended to the end:
172+
Silakan catat hasil dari `toFixed` ialah string. Jika bagian desimal lebih pendek dari yang dibutuhkan, nol ditambahkan di akhir:
173173

174174
```js run
175175
let num = 12.34;
176-
alert( num.toFixed(5) ); // "12.34000", added zeroes to make exactly 5 digits
176+
alert( num.toFixed(5) ); // "12.34000", tambah nol supaya tepat 5 digit
177177
```
178178

179-
We can convert it to a number using the unary plus or a `Number()` call: `+num.toFixed(5)`.
179+
Kita bisa mengkonversi itu ke angka menggunakan unary plus atau panggilan `Number()`: `+num.toFixed(5)`.
180180

181181
## Imprecise calculations
182182

@@ -408,7 +408,7 @@ A few examples:
408408
409409
There are more functions and constants in `Math` object, including trigonometry, which you can find in the [docs for the Math](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math) object.
410410
411-
## Summary
411+
## Kesimpulan
412412
413413
To write numbers with many zeroes:
414414

0 commit comments

Comments
 (0)