BASIC stamp manual v2.2
4: BASIC Stamp Architecture – ATN, HYP, MIN
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 115
Figure 4.2: ATN and HYP operators
in the PBASIC unit circle
The Hypotenuse operator (HYP) returns the length of the hypotenuse of a
right triangle with sides of length A and B. The syntax of HYP is:
SideA HYP SideB
where SideA and SideB are the side lengths of a right-triangle (the order
isn’t important). Another application of HYP is to calculate the distance
between the origin (0, 0) and a point (X, Y) in a Cartesian coordinate
system. Side length (vector) input values are limited to -127 to 127 (signed
bytes). See diagram with ATN operator, Figure 4.2.
DEBUG ? 3 HYP 4 ' hypotenuse of 3x4 triangle (5)
The Minimum operator (MIN) limits a value to a specified 16-bit positive
minimum. The syntax of MIN is:
value MIN limit
where value is a constant or variable value to perform the MIN function
upon and limit is the minimum value that value is allowed to be. Its logic
is, ‘if value is less than limit, then make result = limit; if value is greater than
or equal to limit, make result = value.’
MINIMUM: MIN
H
YPOTENUSE: HYP
All
2
1
A
ll
2