Skip to content · ⁨Lompat ke konten⁩

Sign of a number · ⁨Isyarat satu nombor⁩

English

Sign of a number

Return a number that describes the sign of n: -1 when n is negative, 1 when it is positive, and 0 when it is exactly zero.

Use if to test the cases. The order matters — handle negative and positive first, then return 0 for what is left.

Bahasa Indonesia

Tanda sebuah angka

Kembalikan angka yang mendeskripsikan tanda dari n: -1 ketika n negatif, 1 ketika positif, dan 0 ketika tepat nol.

Gunakan if untuk menguji kasus-kasus tersebut. Urutannya penting — tangani negatif dan positif terlebih dahulu, lalu kembalikan 0 untuk sisanya.

Log in or create account · ⁨Masuk atau buat akun⁩

IGCSE, A-Level & AP