Positron Compiler Documentation

Isqr

Source: Positron16 Compiler User Manual, PDF page 114

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 = 24FJ64GA002
                                ' Select the device to compile for
Declare Xtal = 16
                         ' Tell the compiler the device will be operating at 16MHz
Declare Hserial_Baud = 9600    ' USART1 Baud rate
Declare Hrsout1_Pin = PORTB.14 ' Select the pin for TX with USART1
Dim ByteIn as Byte
                                ' Holds the value to Cos
Dim ByteOut as Byte
                                ' Holds the result of the Cos
RPOR7 = 3
                                ' Make PPS Pin RP14 U1TX
ByteIn = 123
                                ' Load the variable
ByteOut = ISqr(ByteIn)
                                ' Extract the integer square root of the value
HrsoutLn Dec ByteOut
                                ' Display the result

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