math
Integer math. There are no floats, so sin() and cos() return values
scaled by 256. Multiply first, then divide:
from ti84 import math
x = center + radius * math.cos(angle) // 256
y = center + radius * math.sin(angle) // 256
On classic, integers are 16-bit, so radius * math.cos(angle) overflows once
radius passes 127.
abs(), min(), and max() are also built in, and need no import on assembly
targets.
Methods
- abs(value) int
Absolute value.
- Targets:
CE, Classic, Flash App
z = math.abs(x)
- min(a, b) int
Smaller value.
- Targets:
CE, Classic, Flash App
z = math.min(x, y)
- max(a, b) int
Larger value.
- Targets:
CE, Classic, Flash App
z = math.max(x, y)
- clamp(value, low, high) int
Limit a value to a range.
- Targets:
CE, Classic, Flash App
z = math.clamp(x, 0, y)
- sign(value) int
-1, 0, or 1.
- Targets:
CE, Classic, Flash App
z = math.sign(x)
- sqrt(value) int
Integer square root.
- Targets:
CE, Classic, Flash App
z = math.sqrt(x)
- pow(base, exponent) int
Integer power; wraps at the target’s integer width.
- Targets:
CE, Classic, Flash App
z = math.pow(x, 2)
- sin(degrees) int
Sine of an angle in degrees, scaled by 256.
- Targets:
CE, Classic, Flash App
z = math.sin(x)
- cos(degrees) int
Cosine of an angle in degrees, scaled by 256.
- Targets:
CE, Classic, Flash App
z = math.cos(x)