Shorthand numeric updates: Difference between revisions

From Color 64 BBS Wiki
Created page with "Color 64 allows a numeric variable or numeric array element to be updated without repeating the variable name on the right side of the assignment. For example: <strong>A+12</strong> is equivalent to: <strong>A=A+12</strong> Subtraction is also supported: <strong>A-12</strong> is equivalent to: <strong>A=A-12</strong> When no expression follows the operator, Color 64 assumes a value of one: <strong>A+</strong> is equivalent to: <strong>A=A+1</strong> <strong>A-</stron..."
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
[[programming features|Programming Features]] - <strong>Shorthand Numeric Updates</strong>
Color 64 allows a numeric variable or numeric array element to be updated without repeating the variable name on the right side of the assignment.
Color 64 allows a numeric variable or numeric array element to be updated without repeating the variable name on the right side of the assignment.


Line 20: Line 22:


Note: Shorthand updates to integer variables use direct 16-bit arithmetic. If the result exceeds the integer range of -32768 through 32767, the value may wrap around rather than generate an overflow error.
Note: Shorthand updates to integer variables use direct 16-bit arithmetic. If the result exceeds the integer range of -32768 through 32767, the value may wrap around rather than generate an overflow error.
Next Section: [[ml command set|ML Command Set]]

Latest revision as of 14:22, 29 July 2026

Programming Features - Shorthand Numeric Updates

Color 64 allows a numeric variable or numeric array element to be updated without repeating the variable name on the right side of the assignment.

For example: A+12 is equivalent to: A=A+12

Subtraction is also supported: A-12 is equivalent to: A=A-12

When no expression follows the operator, Color 64 assumes a value of one: A+ is equivalent to: A=A+1

A- is equivalent to: A=A-1

The value following the operator may be any valid numeric BASIC expression. For example:

  • A+X*2
  • A-(B+C)
  • HM+
  • N%(I)-1

Both floating-point and integer variables are supported, including array elements. String variables are not supported by this shorthand syntax.

Only the addition (+) and subtraction (-) operators should be used. Other arithmetic or logical operators are not supported in this form.

Note: Shorthand updates to integer variables use direct 16-bit arithmetic. If the result exceeds the integer range of -32768 through 32767, the value may wrap around rather than generate an overflow error.

Next Section: ML Command Set