Slide 21 of 37

Conversions

Parsing text
proc main(): void {
	if hive.conv.sti("42") is Result.Ok(n) {
		echo n + 1
	}
}
Rounding and widening
proc main(): void {
	half := hive.conv.itf(5) / 2.0   // widen first — Int and Float never mix
	echo hive.conv.round(half)
	echo hive.conv.fts(half)
	echo hive.conv.its(hive.conv.ceil(half))
}
hive.conv is pure, so it works in a func as well as a proc. ceil, floor and round turn a Float into an Int, rounding half away from zero; itf widens an Int to a Float, and its/fts render a number as a Str. sti and stf parse text back into a number and, since parsing can fail, answer with a Result whose ConversionError carries the offending input. There is no implicit numeric conversion anywhere else in the language, which is exactly why this module exists: an Int never quietly becomes a Float.