Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
math.round
math.round(numericExpression, decimalPlaces)
Deskripsi
Menampilkan nilai yang dibulatkan ke bilangan bulat terdekat atau ke jumlah tempat desimal yang ditentukan.
Jenis data parameter
NUMBER
Jenis hasil yang ditampilkan
NUMBER
Contoh kode
math.round(10.7) // returns 11
math.round(1.2567, 2) // returns 1.25
math.round(0-10.7) // returns -11
math.round(0-1.2) // returns -1
math.round(4) // returns 4, math.round(integer) returns the integer
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-01-23 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-01-23 UTC."],[[["`math.round` function rounds a numeric value to the nearest integer or a specified number of decimal places."],["The function supports `NUMBER` as the input data type and returns a `NUMBER` type value."],["If no decimal places are specified, the function rounds to the nearest whole number."],["Negative values can be used and will be rounded accordingly to the nearest negative whole number or to the specified negative decimal place."],["The function is available within the context of `Search` as described in the documentation."]]],[]]