Petit Computer Wiki
Petit Computer Wiki
Advertisement

V1[]

Indications are, SGN in SmileBasic V1 is identical to that in V2.

V2[]

SGN is a function which takes one numerical parameter, and returns the 'sign' of the number.

If the parameter is zero, SGN returns zero. If the parameter is positive, then SGN returns 1, and if the parameter is negative, SGN returns -1. As such, when the parameter is nonzero, SGN(X) evaluates to the same as X/ABS(X)... except when X is the 'buggy' value -0.

If the parameter is missing, the system produces Syntax error (SGN), if the parameter is a string, the system givs a Type Mismatch (SGN) error, and if two or more parameters are passed, the system gives the misleading Missing operand (SGN) error.

V3[]

Indications are, SGN in SmileBasic V3 is identical to that in V2, except hopefully, the "-0" bug is fixed.

Advertisement