Skip to content · ⁨Bỏ qua nội dung⁩

Sign of a number · ⁨Dấu của một số⁩

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.

Tiếng Việt

Dấu của một số

Trả về một số mô tả dấu của n: -1 khi n âm, 1 khi nó dương, và 0 khi nó bằng không chính xác.

Sử dụng if để kiểm tra các trường hợp. Thứ tự quan trọng — xử lý số âm và số dương trước, sau đó trả về 0 cho phần còn lại.

Log in or create account · ⁨Đăng nhập hoặc tạo tài khoản⁩

IGCSE, A-Level & AP