Differences
This shows you the differences between two versions of the page.
| Previous revision | |||
| — | sqr [2026/09/18 17:23] (current) – [Examples] jjflash | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== SQR ====== | ||
| + | |||
| + | The '' | ||
| + | |||
| + | ===== Function header ===== | ||
| + | |||
| + | <code xcbasic> | ||
| + | DECLARE FUNCTION SQR AS BYTE (num AS INT) SHARED STATIC INLINE | ||
| + | DECLARE FUNCTION SQR AS BYTE (num AS WORD) OVERLOAD SHARED STATIC INLINE | ||
| + | DECLARE FUNCTION SQR AS WORD (num AS LONG) OVERLOAD SHARED STATIC INLINE | ||
| + | DECLARE FUNCTION SQR AS FLOAT (num AS FLOAT) OVERLOAD SHARED STATIC INLINE | ||
| + | </ | ||
| + | |||
| + | If the argument is a FLOAT, the return value will also be a FLOAT, as accurate as possible. However if the argument is an INT, WORD or LONG, the return value will be a BYTE or WORD, without any fractional part. | ||
| + | ===== Examples ===== | ||
| + | |||
| + | <code xcbasic> | ||
| + | PRINT SQR(2) ' outputs 1 | ||
| + | PRINT SQR(2.0) ' outputs 1.41421 | ||
| + | </ | ||
| + | |||
| + | In the first line, the argument is 2. Since 2 doesn' | ||
| + | |||
| + | In the second line we use the literal 2.0 that the compiler recognizes as FLOAT and therefore the best match is the function accepting a FLOAT argument and returning a FLOAT. | ||
| + | ===== See also ===== | ||
| + | |||
| + | * [[POW]] | ||