{{htmlmetatags>metatag-robots=() metatag-title=(SGN | ugBASIC User Manual) metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum) metatag-description=(Manual page for SGN) metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png) metatag-og:title=(SGN | ugBASIC User Manual) metatag-og:description=(Manual page for SGN) }} ====== ugBASIC User Manual ====== ===== SGN ✓ ===== ===== SYNTAX ===== = SGN(number) ==== PURPOSE ==== The ''SGN'' function is a very simple but useful mathematical function. Its main function is to determine the sign of a number. In other words, ''SGN'' tells you whether a number is positive, negative, or zero. So, it returns 1 if number is positive, 0 if ''number'' is zero and -1 if ''number'' is negative. You can use ''SGN'' inside an ''IF'' condition to perform different actions depending on the sign of a number, and in some cases, ''SGN'' can make your code more concise and readable. ==== EXAMPLE ==== x = SNG(-42) See also the following example files: * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/maths_signs_01.bas|maths_signs_01.bas]]'' ==== ABBREVIATION ==== Sg ==== AVAILABLE ON ==== ==== ANY PROBLEM? ==== If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=ISSUE ON SGN|open an issue]] for this keyword on GitHub. Thank you!===== POWERED BY ===== [[:ugbasic:user:index|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]