Proving the Number of Digits in a Number Formula: A Scientific Exploration

  • Thread starter Buri
  • Start date
In summary: Funny how you actually mentioned algorithms. I actually got into this problem by looking at the efficiency of the Euclidean Algorithm. I was trying to show that when the Euclidean Algorithm is applied to a non-negative real number, that it terminates in at most 7 times the number of digits of the number.
  • #1
Buri
273
0
I was playing around with my calculator and I noticed that to calculate the number of digits in a number n we have # of digits in n = [log(n) + 1], where log is in base 10 and [] represents the floor function. I after looked this up and it seems like its true. But how would you go about proving something like this? I thought of writing n as its decimal expansion, and then taking the logarithm, but it doesn't seem to get me no where. Any ideas?
 
Physics news on Phys.org
  • #2
Let x be a number, then it is easy to see that

x has n digits if and only if [tex]10^{n-1}\leq x<10^{n}[/tex].

If we apply your expression on this, then we obtain

[tex]n=\log(10^{n-1})+1\leq \log(x)+1<\log(10^n)+1=n+1[/tex]

This yields that [tex][\log(x)+1]=n[/tex].
 
  • #3
A number, n, has "d" digits if and only if [itex]10^{d-1}\le n< 10^d[/itex]. Take the logarithm (base 10) of each part of that, using the fact that logarithm is an increasing function.
 
  • #4
Ahhh didn't think of that. Thanks a lot to both of you! :)
 
  • #5
Buri said:
Ahhh didn't think of that. Thanks a lot to both of you! :)

Note that this can be generalized to any base b system. In particular, the number of bits needed to represent a number in base 2 is the log of that number to the base 2. This is really important in the analysis of algorithms.
 
  • #6
Robert1986 said:
Note that this can be generalized to any base b system. In particular, the number of bits needed to represent a number in base 2 is the log of that number to the base 2. This is really important in the analysis of algorithms.

Funny how you actually mentioned algorithms. I actually got into this problem by looking at the efficiency of the Euclidean Algorithm. I was trying to show that when the Euclidean Algorithm is applied to a and b (a > b) that it terminates in at most 7 times the number of digits of b.
 

1. How do you determine the number of digits in a number?

The number of digits in a number can be determined by counting the number of individual digits in the number. For example, the number 123 has three digits.

2. What is the maximum number of digits in a number?

The maximum number of digits in a number depends on the type of number. For example, a 32-bit integer can have a maximum of 10 digits, while a 64-bit integer can have a maximum of 19 digits.

3. Is there a difference between the number of digits in a positive and negative number?

Yes, there is a difference. The number of digits in a positive and negative number is the same, but the negative sign counts as one of the digits in a negative number.

4. Can a number have an infinite number of digits?

No, a number cannot have an infinite number of digits. In mathematics, there are infinite numbers, but when it comes to representing numbers in a computer system, there is a limit to the number of digits a number can have.

5. How can the number of digits in a number impact calculations?

The number of digits in a number can impact calculations by affecting the accuracy and precision of the result. For example, a number with a large number of digits may result in rounding errors or loss of precision in calculations.

Similar threads

  • Linear and Abstract Algebra
Replies
1
Views
637
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
2K
  • General Math
Replies
11
Views
1K
  • Computing and Technology
Replies
4
Views
765
  • Calculus and Beyond Homework Help
Replies
32
Views
2K
Replies
4
Views
410
  • Precalculus Mathematics Homework Help
Replies
2
Views
903
  • General Math
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
953
Replies
4
Views
928
Back
Top