Slide 22 of 37

Math

proc main(): void {
	radius := 3.0
	area := hive.math.pi() * radius ** 2.0
	echo area

	echo hive.math.sqrt(hive.math.hypot(3.0, 4.0))
	echo hive.math.max(hive.math.min(2.0, 5.0), 1.0)
	echo hive.math.clamp(120.0, 0.0, 100.0)
}
hive.math is pure, and every one of its thirteen functions takes and answers with a Float — there is no integer twin, because Hive never widens a number behind your back. pi is the one constant; sin, cos, tan and their inverses asin, acos and atan2 cover angles; sqrt, hypot and abs cover distances; min, max and clamp cover bounds, with clamp defined as exactly min(max(v, low), high), so a range given backwards answers with the high bound. None of it reports an error: a value outside a function's domain simply answers with whatever non-finite Float the arithmetic already produces.