Skip to content · ⁨본문 바로가기⁩

Sign of a number

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.

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP