Integers and floating-point values are the basic building blocks of arithmetic a
ID: 3679023 • Letter: I
Question
Integers and floating-point values are the basic building blocks of arithmetic and computation. A real number is a number that can contain a fractional part. Basically, computers are integer machines and are capable of representing real numbers only by using complex codes. The most popular code for representing real numbers is called the IEEE floating-point standard.
The term floating point is derived from the fact that there is no fixed number of digits before and after the decimal point; that is, the decimal point can float. There are also representations in which the number of digits before and after the decimal point is set, called fixed-point representations. In general, floating-point representations are slower and less accurate than fixed-point representations, but they can handle a larger range of numbers.
What are the advantages and disadvantage of integers and floating numbers? Give two different applications that need hardware capable of handling floating numbers, not integer numbers. What would happen if these applications’ inputs are floating point numbers but they are designed to only handle integers?
Explanation / Answer
Floating point -
1. Advantage Provides a very large range
2. Disadvantage Rounds off large numbers
Fixed point -
1. Advantage Numbers are represented exactly (Used when 'money' is involved)
2. Disadvantage Provide a very limited range
Floating-point numbers have two advantages over integers. First, they can represent values between integers. Second, because of the scaling factor, they can represent a much greater range of values. On the other hand, floating point operations usually are slightly slower than integer operations, and you can lose precision.
Floating point numbers are good for, well, floating points, i.e. when you need to express numbers across varying scales. You sacrifice precision to gain range of scale.
On the other hand, fixed point numbers are only suitable at a fixed scale (and they'll over- or underrun if you scale them too much), but you gain precision as long as you remain within the desired scale.
In short: If you multiply a lot but don't add numbers of different scales, use floating points. If you add a lot but don't multiply, use fixed points.
(A good example of a fixed-point use case is anything relating with currency: Essentially, you can fix your unit to be cents, or one hundredth of a cent, and make all your monetary values be integers in that unit.)
Simply stated, floating points achieve a high domain (from very small numbers close to zero to very high numbers, sometimes even higher than the number of atoms in the universe). Floating points achieve this by keeping the relative error constant. I.e. the number will start to be rounded after an fixed number of decimals (this is a simplification, but helps to understand the principle). This is very similar to the concept of "significant figures" from most natural sciences. However this means that floating point numbers are always somehow rounded. If you add a very small number to a very big number, the small number will just be truncated and the big number will stay. This happens when the small number is below the the threshold. If you add many numbers it might sometimes be necessary to sort them first and adding the small ones before the big ones. There is also the concept of numeric stability to consider, i.e. how an algorithm will drift of from the correct result due to the rounding.
Fixed point representation on the other hand will always have the same absolute error. If you store currency with 4 decimal places, you know your data will be off by a maximum of .00005 cent. If you add your data however, this error again might accumulate, but the rules for this are a lot different from the rules for floating points.
Fixed pointed numbers can be sorted in linear time. Fixed point is also unambiguous; each numerical value that can be expressed in specific fixed point protocol has only one representation, which isn't true with floating point.
Floating point has a much wider representable range. It is also ambiguous. Floating point numbers can be sorted in NlogN time.
Advantages and disadvantage of integers and floating numbersAdvantages
i)They can represent values between integers.
ii)Due to scaling factor, they can represent a much greater range of values.
Disadvantage
i)Floating point operations are generally slightly slower than integer operations and thismay cause loss of precision.
ii)Floating-point numbers cannot represent exactly certain numbers.
Different applications that need hardware capable of handling floating numbers and not integernumbers include;Video and Audio Data Set RequirementsThe advantages of using the floating-point numbers can be easily seen by contrasting the data setrequirements of video and audio applications. The pixel data is normally represented in shortwords of 8 to 12 bits, one for each of the red, green and blue (RGB) planes of the image.
Real-world numerical catastrophes.
The examples we've discussed above are rather simplistic. However, these issues arise in real applications. When done incorrectly, disaster can quickly strike.
Vancouver stock exchange. Vancouver stock exchange index was undervalued by over 50% after 22 months of accumulated roundoff error. The obvious algorithm is to add up all the stock prices after Instead a "clever" analyst decided it would be more efficient to recompute the index by adding the net change of a stock after each trade. This computation was done using four decimal places and truncating (not rounding) the result to three
The main challenge is smart card deos not support Float or double types supports onlyinteger and short type
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.