Concept
How can a while loop normalize a number by repeatedly dividing it by 10?
ComputerScienceOne / Normalizing a Number
"Let’s revisit the example from Section 4.1.1 in which we normalize a number by continually dividing it by 10 until it is less than 10. The code in Code Sample 28.7 specifically refers to the value 32145.234 but would work equally well with any value of x.\n\ndouble x = 32145.234;\n\nint k = 0;\n\nwhile(x > 10) {\n\nx = x / 10; //or: x /= 10;\n\nk++;\n\n}\n\nCode Sample 28.7.: Normalizing a Number with a While Loop in Java"
Related Ideas
- How do you normalize a number with a while loop in C?ComputerScienceOne · Summation
- What is 17?ComputerScienceOne · Normalizing a Number
- How is a basic while loop structured in Java?ComputerScienceOne · While Loops
- What are the while loop algorithms listed here?ComputerScienceOne · Computing Tax Credit with If-Else-If . . . . . . . . . . . . . . . . . . . . .
- How does a flag-controlled while loop work in Java?ComputerScienceOne · While Loops
- Why should you avoid a semicolon after a while-loop condition?ComputerScienceOne · While Loops
- How can a for loop calculate the sum of numbers from 1 to 10?ComputerScienceOne · Nested Loops
- How can a summation loop be generalized to sum up to a variable n?ComputerScienceOne · Summation