17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

GW-BASIC <strong>User's</strong> Guide<br />

SGN Function<br />

Purpose:<br />

To return the sign of x.<br />

Syntax:<br />

SGN(x)<br />

Comments:<br />

x is any numeric expression.<br />

If x is positive, SGN(x) returns 1.<br />

If x is 0, SGN(x) returns 0.<br />

If x is negative, SGN(x) returns -1.<br />

This statement is similar to, but not the same as SIN(x), which returns a trigonometric function<br />

in radians, rather than in ones and zeros.<br />

Examples:<br />

10 INPUT "Enter value", x<br />

20 ON SGN(X)+2 GOTO 100, 200, 300<br />

GW-BASIC branches to 100 if X is negative, 200 if X is 0, and 300 if X is positive.<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/SGN.html28/03/2004 21.29.46

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!