user9623401
user9623401

Reputation:

float -point numbers can only represent fixed set of numbers?

I was reading a textbook which gives an example of nonnegative values for 8-bit floating-point format as below:

enter image description here

So it seems that float-point numbers has limitations as they can only represent fixed set of numbers. For example, 0.001 to 0.001952 or 0.876 to 0.9374 can not be represented, so there are "gaps" everywhere, so what's the point to use floating point numbers?

Upvotes: 1

Views: 88

Answers (1)

Eric Postpischil
Eric Postpischil

Reputation: 222660

Floating-point arithmetic approximates real-number arithmetic.

This is possible to do using a finite set of numbers.

Floating-point algorithms produce results that are, hopefully, approximations of the results that would be obtained with real-number arithmetic. Obtaining approximations of ideal results is useful, and hence this is “the point to use floating point numbers.”

As an example, if we use floating-point arithmetic to estimate the position of a vehicle after certain maneuvers, this can be used to guide the vehicle. It is not necessary to use perfect real-number arithmetic to get a result that is good enough; floating-point arithmetic, used properly, serves well enough. If we get the vehicle close enough to its target, within a certain margin, we do not need it to be perfectly centered.

Eight-bit formats have limited usefulness. Although they may have some real-world uses, they may be primarily used for teaching. Larger formats generally offer more precision, with the result that errors due to approximations often may be made negligible. (Nonetheless, there are a variety of foibles to numerical arithmetic; there is an entire field of study for it, called numerical analysis.)

Upvotes: 0

Related Questions