Ready to practice?
Sign up to access interactive coding exercises and track your progress.
Scientific Notation Fundamentals
Represent very large and very small numbers using scientific notation in C++.
What is scientific notation?
Scientific notation provides a compact way to write very large or very small numbers. Understanding scientific notation helps you grasp how floating-point numbers work - and crucially, their limitations.
Scientific notation follows this pattern: significand x 10^exponent. For example, 2.5 x 10^3 equals 2,500.
In C++, we use 'e' to represent "times 10 to the power of":
2.5e3means 2.5 x 10^3 = 2,5001.898e27means 1.898 x 10^273e-2means 3 x 10^-2 = 0.03
Significant digits
The digits in the significand (the part before 'e') are called significant digits (or significant figures). More significant digits means greater precision.
3.14has 3 significant digits3.14159has 6 significant digits
More digits in the significand equals greater precision.
Converting to scientific notation
Follow this procedure:
- Start with exponent zero
- Slide the decimal point until exactly one non-zero digit appears left of it
- Each leftward movement increases the exponent by 1
- Each rightward movement decreases the exponent by 1
- Remove leading zeros
- For trailing zeros:
- Keep them if the original number had a decimal point
- Remove them if the original number had no decimal point
Examples:
750.820 -> 7.50820e2 (6 significant digits)
0.0056300 -> 5.6300e-3 (5 significant digits)
85070 -> 8.507e4 (4 significant digits, trailing zero dropped)
85070. -> 8.5070e4 (5 significant digits, trailing zero kept due to decimal)
Why trailing zeros matter
When a number has a decimal point, trailing zeros indicate precision:
125.0gmeans the measurement is precise to 0.1g125.000gmeans the measurement is precise to 0.001g
In scientific notation:
125.0g=1.250e2(4 significant digits)125.000g=1.25000e2(6 significant digits)
When C++ stores a floating-point number in memory, it stores just the value. There's no way to determine whether the original was 125.0 or 125.000 - both are stored as 125.
Now that we've covered scientific notation, we're ready to explore floating-point numbers.
Scientific Notation Fundamentals - Quiz
Test your understanding of the lesson.
Practice Exercises
Scientific Notation Practice
Work with very large and very small numbers using scientific notation in C++.
Lesson Discussion
Share your thoughts and questions
No comments yet. Be the first to share your thoughts!