Curriculum Foundations Numeric primitives
Numeric primitives
TypeScript has one number type. Go has many: int, int8, int16, int32, int64, uint* mirrors, float32, and float64. The big idea: Go has no implicit numeric conversion. A function expecting int64 will not accept an int32 without an explicit cast. This frustrates briefly, then becomes a feature.
9 ready
01
pick one TypeScript collapses all numbers into one number type. Go
02
pick oneAdding a decimal point to a literal changes its default Go type.
03
pick oneGo requires *explicit* conversion between numeric types. TypeScript
04
fill blanksExercise 2 covered which Go type a decimal literal defaults to. Now
05
fill blanksExercise 3 introduced Go's explicit-conversion shape — call the target
06
type one line double is already a float64; count is an int. They can't
07
type one line Type the Go declaration that holds the value 1_000_000_000 safely
08
write a program Write a Go program that declares an int named count set to 42,
09
write a program Write a Go program that prints the maximum value of an int8 and