Scale Factor (computer Science) - Picking A Scale Factor

Picking A Scale Factor

An example above illustrated how certain scale factors can cause unnecessary precision loss. We will revisit this example to further explore the situation.

We're storing representations of real data in 8 bit unsigned fixed point fields with 4 integer bits and 4 fractional bits. This gives us a range of in decimal, or in hex. Our real world data is all integers and in the range in decimal. Note that there are only 161 unique values that we may want to store, so our 8 bit field should be plenty, since 8 bits can have 256 unique configurations.

In the example given above, we picked a scale factor of 11 so that all the numbers would be small enough to fit in the range. However, when we began scaling the following real world data:

154, 101, 54, 3, 0, 160

We discovered that the precision of these fractions is going to be a problem. The following box illustrates this showing the original data, its scaled decimal values, and the binary equivalent of the scaled value.

154/11 = 14 = 1110.0 101/11 = 9.1818... = 1001.00101110... 54/11 = 4.9090... = 100.111010... 3/11 = 0.2727... = 0.010010... 0/11 = 0 = 0.0 160/11 = 14.5454... = 1110.10010...

Notice how several of the binary fractions require more than the 4 fractional bits provided by our fixed point format. To fit them into our fields, we would simply truncate the remaining bits, giving us the following stored representations:

1110.0000 1001.0010 0100.1110 0000.0100 0000.0000 1110.1001

Or in decimal:

14.0 9.125 4.875 0.25 0.0 14.5625

And when we need to bring them back into the real world, we need to divide by our scale factor, 1/11, giving the following "real world" values:

154.0 100.375 53.625 2.75 0 160.1875

Notice how they've changed? For one thing, they aren't all integers anymore, immediately indicating that an error was introduced in the storage, due to a poor choice of scaling factor.

Read more about this topic:  Scale Factor (computer Science)

Famous quotes containing the words picking a, picking, scale and/or factor:

    —Thus their hands are plucking at each other;
    Picking at the rope-knouts of their scourging;
    Snatching after us who smote them, brother,
    Pawing us who dealt them war and madness.
    Wilfred Owen (1893–1918)

    Is it not singular that, while the religious world is gradually picking to pieces its old testaments, here are some coming slowly after, on the seashore, picking up the durable relics of perhaps older books, and putting them together again?
    Henry David Thoreau (1817–1862)

    The Humanity of men and women is inversely proportional to their Numbers. A Crowd is no more human than an Avalanche or a Whirlwind. A rabble of men and women stands lower in the scale of moral and intellectual being than a herd of Swine or of Jackals.
    Aldous Huxley (1894–1963)

    In his very rejection of art Walt Whitman is an artist. He tried to produce a certain effect by certain means and he succeeded.... He stands apart, and the chief value of his work is in its prophecy, not in its performance. He has begun a prelude to larger themes. He is the herald to a new era. As a man he is the precursor of a fresh type. He is a factor in the heroic and spiritual evolution of the human being. If Poetry has passed him by, Philosophy will take note of him.
    Oscar Wilde (1854–1900)