Lessons
Lesson 1: Valid Uint Sizes
Learn about unsigned integers and their supported bit sizes in Solidity.
Start LessonLesson 2: Maximum Integer Size
Learn how to calculate the maximum values that different uint types can store.
Start LessonLesson 3: Smallest Number of Bits Required to Hold a Number
Learn how to calculate the minimum uint size needed to store specific values.
Start LessonLesson 4: Overflow Due to Addition
Learn how to prevent overflow when adding values in Solidity.
Start LessonLesson 5: Overflow Due to Multiplication
Learn how to calculate maximum values to prevent multiplication overflow.
Start LessonLesson 6: Overflow Due to Exponentiation
Learn how to calculate maximum exponents to prevent overflow in power operations.
Start LessonLesson 7: Solidity Upcasting Rule
Learn how Solidity determines the result type when combining different uint sizes.
Start LessonLesson 8: Maximum Value on Addition and Multiplication
Learn to calculate maximum return values considering both operation and return type limits.
Start LessonLesson 9: Uint Sizes of Constants
Learn how Solidity automatically assigns uint sizes to constants and their impact on operations.
Start LessonLesson 10: Division of Unsigned Integers
Learn how integer division works in Solidity and why it always rounds down.
Start LessonLesson 11: Modulus
Learn how to calculate remainders using the modulus operator in Solidity.
Start LessonLesson 12: Modulus to Detect Divisibility
Learn how to use modulus to check if numbers are divisible and write boolean conditions.
Start LessonLesson 13: Units of Time
Learn how Solidity's time unit suffixes work and their conversion to seconds.
Start LessonLesson 14: Units of Ether
Learn how Solidity's Ether unit suffixes work and their conversion to wei.
Start LessonLesson 15: Scientific Notation
Learn how to use scientific notation (1e18) for large numbers in Solidity.
Start LessonLesson 16: Rounding Down Disallowed Constants
Learn how to fix compilation errors when dividing constants that don't result in exact integers.
Start LessonLesson 17: Rounding Up Disallowed Constants
Learn how to round constants up to the next valid value when division doesn't result in exact integers.
Start LessonLesson 18: Coefficients with decimals
Learn how Solidity allows decimal coefficients as long as the final result is a whole number.
Start LessonLesson 19: Division Rounding Up
Learn how to implement division that rounds up to the next integer instead of truncating.
Start LessonLesson 20: Upcasting with time and ether suffixes
Learn how time and ether suffixes affect type upcasting and overflow calculations.
Start LessonLesson 21: Unchecked overflow
Learn how unchecked blocks allow arithmetic overflow and how to calculate the resulting values.
Start LessonLesson 22: Year to overflow for timestamps
Learn to calculate when timestamps stored in different uint types will overflow in the future.
Start LessonLesson 23: Year to overflow for linearly increasing values
Learn to calculate uint sizes needed for values that grow linearly over time in DeFi applications.
Start LessonLesson 24: Unchecked underflow
Learn how unchecked blocks allow arithmetic underflow and how to calculate the resulting values.
Start LessonLesson 25: Order of Operations 1
Learn how Solidity follows mathematical order of operations with parentheses, exponents, and left-to-right evaluation.
Start LessonLesson 26: Percentage Increases
Learn how to calculate percentage increases in Solidity using integer multiplication and division.
Start LessonLesson 27: Time to overflow for compounding values
Learn to calculate when compounding interest trackers will overflow in lending protocols using logarithmic formulas.
Start LessonLesson 28: Postfix Operators
Learn how to use the ++ and -- operators to increment and decrement variables, including overflow behavior.
Start LessonLesson 29: Signed integer max value
Learn how to calculate the maximum positive values that different signed integer types can store.
Start LessonLesson 30: Signed Integer Minimum Value
Learn how to calculate the minimum negative values that different signed integer types can store.
Start LessonLesson 31: Downcasting
Learn about safe and unsafe type casting, and how to determine maximum values for safe downcasting between different uint sizes.
Start LessonLesson 32: Downcasting is the same as modulo 2ⁿ
Learn how downcasting operations are mathematically equivalent to modulo operations and how to calculate the resulting values.
Start LessonLesson 33: Return value from postfix operators
Learn how postfix operators (++ and --) return the value before increment/decrement and how to work with their dual behavior.
Start LessonLesson 34: Hexadecimal Numbers
Learn how to convert hexadecimal numbers to decimal using base-16 positional notation and hexadecimal digit values.
Start LessonLesson 35: Maximum uint size in hexadecimal
Learn how to express maximum uint values in hexadecimal notation using the relationship between bits, bytes, and 0xff patterns.
Start LessonFixed Point Numbers
Lesson 36: Scaling Factors for Fixed Point Numbers
Learn how scaling factors work in fixed-point arithmetic and how to convert between stored and interpreted values.
Start LessonLesson 37: Adding fixed-point numbers with the same scaling factor
Learn how to add fixed-point numbers by simply adding their stored values when they share the same scaling factor.
Start LessonLesson 38: Converting an integer to a fixed-point number
Learn how to convert integers to fixed-point representation by multiplying with the scaling factor.
Start LessonLesson 39: Converting a fixed-point number to an integer
Learn how to convert fixed-point numbers back to integers by dividing by the scaling factor and truncating decimals.
Start LessonLesson 40: Adding an integer to a fixed-point number to get a fixed-point number
Learn how to add integers to fixed-point numbers by first converting the integer to fixed-point representation.
Start LessonLesson 41: Adding an integer to a fixed-point number to get an integer
Learn how to add integers to fixed-point numbers by first converting the fixed-point number to an integer.
Start LessonLesson 42: Increasing the scale of a fixed-point number
Learn how to increase the scaling factor of fixed-point numbers by multiplying with the appropriate ratio.
Start LessonLesson 43: Decreasing the scaling factor
Learn how to decrease the scaling factor of fixed-point numbers by dividing with the appropriate ratio.
Start LessonLesson 44: Adding fixed-point numbers with unequal scaling factors
Learn how to add fixed-point numbers with different scaling factors by normalizing them to a common scale.
Start LessonLesson 45: Largest fixed-point number representable in a uint
Learn how to calculate the maximum value that can be represented by different uint types with various scaling factors.
Start LessonMultiplication and Division of Fixed-Point Numbers
Lesson 46: Multiplying fixed-point numbers with the same scaling factor
Learn how to multiply fixed-point numbers with matching scaling factors and handle the result scaling.
Start LessonLesson 47: Smallest value a fixed-point number can represent
Learn how to determine the precision limit of fixed-point numbers based on their scaling factor.
Start LessonLesson 48: Fixed-point multiplication rounding up
Learn how to implement multiplication that rounds up instead of truncating for improved precision.
Start LessonLesson 49: Multiplying fixed-point numbers with integers
Learn how to multiply fixed-point numbers by integers without changing the scaling factor.
Start LessonLesson 50: Multiplying fixed-point numbers with unequal scaling factors
Learn how to multiply fixed-point numbers that have different scaling factors.
Start LessonLesson 51: Dividing fixed-point numbers with the same scaling factor
Learn how to divide fixed-point numbers with matching scaling factors correctly.
Start LessonLesson 52: Dividing fixed-point numbers with integers
Learn how to divide fixed-point numbers by integers while maintaining precision.
Start LessonLesson 53: Integers divided by integers to produce fixed-point numbers
Learn how to divide integers to create fixed-point results with proper scaling.
Start LessonLesson 54: Integers divided by fixed-point numbers
Learn how to divide integers by fixed-point numbers to produce fixed-point results.
Start LessonLesson 55: Dividing fixed-point numbers with unequal scaling factors
Learn how to divide fixed-point numbers that have different scaling factors.
Start LessonQ-Numbers
Lesson 56: Power of 2 Scaling Factors
Learn how power-of-2 scaling factors work and why they enable efficient bitshift operations in fixed-point arithmetic.
Start LessonLesson 57: Binary Representation of Power-of-2 Scaling Factors
Learn how power-of-2 numbers are represented in binary and why this makes bitshift operations efficient.
Start LessonLesson 58: Smallest Value a Power-of-2 Fixed-Point Number Can Represent
Learn how to calculate the precision limits of power-of-2 fixed-point systems.
Start LessonLesson 59: Largest Value a Power-of-2 Fixed-Point Number Can Represent
Learn how to calculate the maximum values that different uint types can store with power-of-2 scaling factors.
Start LessonLesson 60: Largest Integer a Power-of-2 Fixed-Point Number Can Represent
Learn how to determine the maximum whole number values in power-of-2 fixed-point systems using bitwise interpretation.
Start LessonLesson 61: Q-Number Notation
Learn the standard UQm.n notation for power-of-2 fixed-point numbers and how to convert between formats.
Start Lesson