Re: Number of bits needed to represent numbers



On Apr 3, 8:21 am, "Lane Straatman" <inva...@xxxxxxxxxxx> wrote:
"Quadibloc" <jsav...@xxxxxxxxx> wrote in message

news:1175344085.630859.183700@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> polymedes wrote:
Suppose we want to calculate the number of bits needed to represent an
integer number, assuming that this number falls in a certain range.

As an example, take the numbers from 68 to 129. How many bits are
needed for binary representation of these numbers?

Isn't this a rather simple question?

Compared to most questions that count as topical around here, the answer is
probably yes.

There are 26 letters of the alphabet. If you wanted to find out how
many bits were needed to specify a letter of the alphabet, what would
you do?

How many integers are there in the range from 68 to 129? What would
you do to find this out? How many integers are there from 1 to 5? Or
from 2 to 6?

There also has to be some accounting for what numbers are *not* being
represented, for example, is a number's inverse included? Just for kicks and
giggles, I'll give the output for how my machine stores 124 as a float:

/* BEGIN output from bitstr.c */

124.000000 = 01000010111110000000000000000000

/* END output from bitstr.c */
Windows doesn't care much about having twice as much width here as it
needed. Certainly however you need something like log_2(n) bits to
represent minimally a positive integer n.
--
LS

Could you give me a proof that the number of bits needed to represent
a range of n numbers if log_2(n)?

.



Relevant Pages

  • Re: What is a "floating-point integer representation"?
    ... Basically, every float has a binary representation, and every binary representation can be expressed as a base-10 integer. ... The reason for representing a float as an integer is that you can write it to a text file without loosing any significance. ... make sure that the machines respect the same storage when reading/writing the data between different machines.) ... % trimmed float ...
    (comp.soft-sys.matlab)
  • Re: What is a "floating-point integer representation"?
    ... Basically, every float has a binary representation, and every binary representation can be expressed as a base-10 integer. ... The reason for representing a float as an integer is that you can write it to a text file without loosing any significance. ... However, in the help of the hex2dec function itself is IMO no reference to the float part necessary, since we only operate with a string and an integer. ...
    (comp.soft-sys.matlab)
  • Re: integer to float
    ... I currently start to work with an TI dsp ... My question is whats happen when I cast an 32Bit integer value ... > into an 32bit float value. ... The binary representation of the integer changes. ...
    (comp.dsp)
  • Re: how the following code works?
    ... oops, you had taken liberty over the size of float! ... the above code gives the binary representation of a. ...
    (comp.lang.c)
  • Re: Number of bits needed to represent numbers
    ... needed for binary representation of these numbers? ... I'll give the output for how my machine stores 124 as a float: ... Windows doesn't care much about having twice as much width here as it ...
    (sci.math.num-analysis)