Chapter
Computing a Logarithm
From ComputerScienceOne by Dr Chris Bourke
Concepts
- Why can an extra semicolon make an if statement behave incorrectly?
"Some compilers may give a warning, but this is valid Java; it will compile and it will run. However, it will end up printing x is less than 10, even though x = 15! Recall that a conditional statement
- What curly-bracket convention should be used with conditional statements?
"Another convention that we’ve used in our code is where we have placed the curly brackets. First, if a conditional statement is bound to only one statement, the curly brackets are not necessary. Howe
- How can a Java program compute a logarithm in an arbitrary base?
"The logarithm of x is the exponent that some base must be raised to get x. The most common logarithm is the natural logarithm, ln(x), which is base e = 2.71828.... But logarithms can be in any base b