4: BASIC Stamp Architecture – MAX
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 71
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.’ MIN works in positive math
only; its comparisons are not valid when used on two’s complement
negative numbers, since the positive-integer representation of a number
like -1 ($FFFF or 65535 in unsigned decimal) is larger than that of a
number like 10 ($000A or 10 decimal). Use MIN only with unsigned
integers. Because of the way fixed-size integers work, you should be
careful when using an expression involving MIN 0. For example, 0-1 MIN
0 will result in 65535 because of the way fixed-size integers wrap around.
SYMBOL Value1 = W0
SYMBOL Value2 = W1
FOR Value1= 100 TO 0 STEP -10 ' Walk value of Value1 from 100 to 0.
Value2 = Value1 MIN 50 ' Use MIN to clamp at 50.
DEBUG Value2 ' Show "clamped" value
NEXT
-- or --
Value1 VAR WORD
FOR Value1= 100 TO 0 STEP 10 ' Walk value of Value1 from 100 to 0.
DEBUG ? Value1 MIN 50 ' Show Value1, but use MIN to clamp at 50.
NEXT
The Maximum operator (MAX) limits a value to a specified 16-bit positive
maximum. The syntax of MAX is:
Value MAX Limit
Where Value is a constant or variable value to perform the MAX function
upon and Limit is the maximum value that Value is allowed to be. Its logic
is, ‘if Value is greater than Limit, then make result = Limit; if Value is less
than or equal to Limit, make result = Value.’ MAX works in positive math
only; its comparisons are not valid when used on two’s complement
negative numbers, since the positive-integer representation of a number
like -1 ($FFFF or 65535 in unsigned decimal) is larger than that of a
number like 10 ($000A or 10 decimal). Use MAX only with unsigned
integers. Because of the way fixed-size integers work, you should be
careful when using an expression involving MAX 65535. For example,
1
2
e
2
sx
2
p
2
M
AXIMUM
: MAX
1
2
e
2
sx
2
p
2
Содержание 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...