type conversion

Turning a value of one type into another, such as the string "23" into the integer 23.

In more detail

Many languages convert by writing the type name like a function call, such as int("23") in Python or float64(used) in Go. Some languages convert between number types automatically; others, such as Go, require every conversion to be written out. Converting a floating-point number to an integer usually throws the fraction away, and a conversion that makes no sense, such as turning "hello" into a number, fails with an error.

Examples

float64(used) / float64(total)
int("23") + 5
str(23) + "5"

Related terms

Taught in

References