BASIC Stamp Architecture – SQR
Page 66
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
To convert brads to degrees, multiply by 180 then divide by 128. To
convert degrees to brads, multiply by 128, then divide by 180. Here’s a
small program that demonstrates the SIN operator:
Degr VAR WORD ' Define variables.
Sine VAR WORD
FOR Degr = 0 TO 359 STEP 45 ' Use degrees.
Sine = SIN (Degr * 128 / 180) ' Convert to brads, do SIN.
DEBUG "Angle: ", DEC Degr, TAB, "Sine: ", SDEC Sine, CR ' Display.
NEXT
The Square Root operator (SQR) computes the integer square root of an
unsigned 16-bit number. (The number must be unsigned since the square
root of a negative number is an ‘imaginary’ number.) Remember that most
square roots have a fractional part that the BASIC Stamp discards when
doing its integer-only math. So it computes the square root of 100 as 10
(correct), but the square root of 99 as 9 (the actual is close to 9.95).
Example:
DEBUG SQR 100 ' Display square root of 100 (10).
DEBUG SQR 99 ' Display of square root of 99 (9 due to truncation)
Table 4.6 lists the available Binary (two-argument) Operators.
Operator
Description
Supported By:
+
Addition
All
-
Subtraction
All
*
Multiplication
All
**
Multiplication (returns upper 16-bits)
All
*/
Multiply by 8-bit integer, 8-bit fraction
All except BS1
/
Division
All
//
Modulus (Remainder of division)
All
MIN
Limits a value to a specified low
All
MAX
Limits a value to a specified high
All
DIG
Returns specified digit of number
All except BS1
<<
Shift bits left by specified amount
All except BS1
>>
Shift bits right by specified amount
All except BS1
REV
Reverse specified number of bits
All except BS1
&
Bitwise AND
All
|
Bitwise OR
All
^
Bitwise XOR
All
&/
Logical AND NOT
Only BS1
|/
Logical OR NOT
Only BS1
^/
Logical XOR NOT
Only BS1
2
e
2
sx
2
p
2
S
QUARE
R
OOT
: SQR
B
INARY
O
PERATORS
.
Table 4.6: Binary Operators. Note:
some binary operators are not
supported by all BASIC Stamps.
Содержание BASIC Stamp 2e
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...