Numbers & Math (Integers, Floats, Math Package) - Go Tutorial for Beginners #4
5views
005:21
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Learn how to work with numbers and math in Go! 🔢
In this lesson, you will learn:
✅ Integer arithmetic operations
✅ Floating point numbers (float32, float64)
✅ Integer vs float division
✅ The math package (Sqrt, Pow, Round, Floor, Ceil)
✅ Type conversions between numeric types
🕐 Timestamps:
0:00 - Introduction
0:24 - Integer Arithmetic
1:12 - Floating Point Numbers
2:05 - Math Package
3:00 - Type Conversions
3:57 - Recap
4:27 - End
💻 Source Code: https://github.com/GoCelesteAI/go_numbers
📚 Code from this lesson:
// Integer arithmetic
a := 17
b := 5
fmt.Println("Div:", a/b) // 3 (truncates)
fmt.Println("Mod:", a%b) // 2 (remainder)
// Float types
var price float64 = 19.99
fmt.Printf("Total: $%.2f\n", price*1.08)
// Math package
math.Sqrt(16) // 4
math.Pow(2, 8) // 256
math.Round(3.7) // 4