Thus in scientific notation this becomes: 1.23 x 10 6 Now the same in Binary.To create this new number we moved the decimal point 6 places.Adjust the number so that only a single digit is to the left of the decimal point.If we want to represent 1230000 in scientific notation we do the following: If we make the exponent negative then we will move it to the left. In this case we move it 6 places to the right. The exponent tells us how many places to move the point. The mantissa is always adjusted so that only a single (non zero) digit is to the left of the decimal point. In the above 1.23 is what is called the mantissa (or significand) and 6 is what is called the exponent. Some of you may remember that you learnt it a while back but would like a refresher. Some of you may be quite familiar with scientific notation. Remind me again how scientific notation works Here I will talk about the IEEE standard for foating point numbers (as it is pretty much the de facto standard which everyone uses). We lose a little bit of accuracy however when dealing with very large or very small values that is generally acceptable. Floating point is quite similar to scientific notation as a means of representing numbers. To get around this we use a method of representing numbers called floating point. It only gets worse as we get further from zero. That's more than twice the number of digits to represent the same value. If we want to represent the decimal value 128 we require 8 binary digits ( 10000000 ). These are a convenient way of representing numbers but as soon as the number we want to represent is very large or very small we find that we need a very large number of bits to represent them. What we have looked at previously is what is called fixed point binary fractions. (or until you end up with 0 in your multiplier or a recurring pattern of bits). This example finishes after 8 bits to the right of the binary point but you may keep going as long as you like. Once you are done you read the value from top to bottom. The easiest approach is a method where we repeatedly multiply the fraction by 2 and recording whether the digit to the left of the decimal point is a 0 or 1 (ie, if the result is greater than 1), then discarding the 1 if it is. Converting decimal fractions to binary is no different. So, for instance, if we are working with 8 bit numbers, it may be agreed that the binary point will be placed between the 4th and 5th bits.Ġ1101001 is then assumed to actually represent 0110.1001 Converting a decimal fraction to binaryĪ lot of operations when working with binary are simply a matter of remembering and applying a simple set of steps. We get around this by aggreeing where the binary point should be. This is fine when we are working with things normally but within a computer this is not feasible as it can only work with 0's and 1's. So far we have represented our binary fractions with the use of a binary point. We will come back to this when we look at converting to binary fractions below. This is not normally an issue becuase we may represent a value to enough binary places that it is close enough for practical purposes. This is the same with binary fractions however the number of values we may not accurately represent is actually larger. 0.3333333333) but we will never exactly represent the value. In decimal, there are various fractions we may not accurately represent. In binary we double the denominator.Īs you move along, the denominator doubles so we end up with the following denominator values: 2 -1Ĭonverting the binary fraction to a decimal fraction is simply a matter of adding the corresponding values for each bit which is a 1. In decimal it is rather easy, as we move each position in the fraction to the right, we add a 0 to the denominator. So in binary the number 101.101 translates as: 1 * 2 2 In binary it is the same process however we use powers of 2 instead. So in decimal the number 56.482 actually translates as: 5 * 10 1 As we move to the right we decrease by 1 (into negative numbers). As we move a position (or digit) to the left, the power we multiply the base (2 in binary) by increases by 1. For a refresher on this read our Introduction to number systems. Binary Fractionsīinary is a positional number system. This is the default means that computers use to work with these types of numbers and is actually officially defined by the IEEE. Then we will look at binary floating point which is a means of representing numbers which allows us to represent both very small fractions and very large integers. In this section, we'll start off by looking at how we represent fractions in binary. Binary fractions introduce some interesting behaviours as we'll see below. Extending this to fractions is not too difficult as we are really just using the same mechanisms that we are already familiar with. Up until now we have dealt with whole numbers.
0 Comments
Leave a Reply. |