ReferenceVerse
Math Abs
math abs
Updated
A pirate crab scuttles too far left from its tide pool, but the game still catches it crossing the boundary line.
In Verse, coordinates and offsets can be negative, but distance is always positive—that’s where the absolute value function steps in.
We start with a negative drift, pass it through Abs to strip the minus sign, and then check if that pure distance breaks our limit.
Reach for Abs whenever you need to measure how far something has moved, no matter which direction it went.
Drift : float = -15.5
Distance : float = Abs(Drift)
if (Distance > 10.0):
Print("Too far from the tide pool!")
Build your own lesson with math-abs
Generate a personalized, compile-checked lesson grounded in this exact reference.
Build a lesson →