Performing math operations in FPGAs (Part 3)
Now, of course, there are plenty of ways one could represent a floating-point number. You can do it your way, I can do it my way, or we can all agree to follow a standard such as the IEEE 754 2008 standard, for example. Of course, I'm not the first person here to cover the topic of floating-point representations; in fact, Mr. Kjodavix described this way back in 2006. Because of Mr. Kjodavix's article, I wondered whether I should even bother expounding on floating-point concepts. However, we all speak a little differently and we all learn a little differently, so maybe my take on this will make someone else's grasp a little better (I do recommend reading Mr. Kjodavix's article, though).
So what are floating-point numbers? Well, let's start with the fact that, due to the way in which we build our computers using two-state logic (let's not worry about experiments with tertiary, or three-state, logic), we have to store numbers using some form of binary representation. It's relatively easy to use binary values to represent integers, but they don't lent themselves to directly storing real numbers; that is, numbers that include fractional values with digits after the decimal point. In other words, it's relatively easy to use binary to represent a value like 3, but it's less easy to represent a value like 3.141592. Similarly, it's relatively easy to create logic functions to implement mathematical operations on integer values, but it's less easy to work with real numbers.
Of course, we can store numbers in BCD (I talked about this in Part 2), or we could use fixed-point representations (I will talk about this next time), but what do we actually mean by floating-point? Well, it's a lot like the "scientific notation" we learned at high school (e.g. 31.41592x10 -1), but it's stored and manipulated using binary representations.
So, how we might perform the mighty feat of representing a real number in binary? If we would just assume a binimal point (the binimal point is the same as the decimal point in base 10, only it's the binary equivalent in base 2) at some fixed point in the middle, then we'd have a fixed-point representation as illustrated below.
|Related Articles||Editor's Choice|