Positron Compiler Documentation

ISqr

Source: Positron8 Compiler User Manual, PDF page 106

Syntax

Assignment Variable = ISqr(pVariable)

Overview

Deduce the integer Square Root of an integer value

Parameter

pVariable can be a constant, variable or expression that requires the Square Root extracted. Assignment Variable can be any valid variable type.

Example

Device = 18F26K40
                                ' Select the device to compile for
Declare Xtal = 16 ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600
                                ' Set the Baud rate for HRsoutLn
Dim ByteIn as Byte
                             ' Holds the value to ISqr
Dim ByteOut as Byte
                             ' Holds the result of the Isqr
ByteIn = 123
                             ' Load the variable
ByteOut = ISqr(ByteIn)
                             ' Extract the integer square root of the value
HRsoutLn Dec ByteOut
                             ' Display the result
Stop

Note

When implementing trigonometry, or other built in, functions within an expression, always wrap them in parenthesis, otherwise the parser may consider the extra operands as part of the trigonometry parameter and produce an incorrect result. For example:

MyAssignment = (Isqr(MyVar1)) + MyVar2