开发者

Numerical Representation of real numbers, alternative to floating-point format

开发者 https://www.devze.com 2023-02-17 23:57 出处:网络
are there any formats to describe real numbers, other than floating point format? In particular, I ask for formats which still provide feasible computation performance (compared to floating point), i

are there any formats to describe real numbers, other than floating point format?

In particular, I ask for formats which still provide feasible computation performance (compared to floating point), in contrast to, say, symbolic computation.

Thank you.

Addendum: I am interested in this from a perspective of theoretical computer science. Indeed I have found a scientific paper which gives a (small list) of number systems to 'represent' a real number. perso.e开发者_如何学Cns-lyon.fr/jean-michel.muller/chapitre1.pdf

The term 'symbolic' is ambigious, I admit. I have been thinking about mathematica like computing, which is a term used in theoretical CS. Btw, 'describe' does not mean 'describe precisely. The term 'float' however does not apply, because that wouldn't make much sense. But this is far adrift from the actual question, being more philosophical.


I really like continued fraction representations. Done lazily, they can let you generate precision as needed. They will, of course, be slower than "native" representations such as floating point.


Well, there are fixed-point formats and fractions (basically a specialized form of symbolic computation), but neither are very popular, probably because they don't have any benefits over float-point except for very specific applications.

What are your requirements anyway? Chances are, floating-point numbers are actually the best fit, they're just often misunderstood as generally "imprecise". In fact, they're actually very precise within certain limits - but every format has such limits, and without specialized hardware, anything that is more precise will be several orders of magnitude slower.


I'm not sure this is exactly what you are looking for, but...
For embedded programming, we sometimes store values as signed 0.15 fixed point with an associated scale factor. You can think of it as storing all values as fractions between -1..1 and keeping track of a multiplier along with the units. So for example to represent 5 amps in a variable scaled to 10A, you would do:

 int16 I = 16384; //.5@10A = 5A

When you do math, you just keep track of the scale along with the units.

 int16 R = 3277 //.1@2ohm = .2ohm
 int16 V = ((int32)I*R)>>15; //@10A*@2Ohm = @20V
 //result = 1638 => 1638/32768= .05@20V = 1V

It takes a lot of attention to detail to work with this system, but on a system with a slow or no floating point processor, it is a way to maintain arbitrary precision and super fast operations.


In particular, I ask for formats which still provide feasible computation performance (compared to floating point), in contrast to, say, symbolic computation.

Depends entirely on what you mean by "feasible". Is there anything that can do floating-point style computations at anywhere close to modern hardware floating point speed? No. Anything other than the native hardware operations is orders of magnitude slower.

That said, modern hardware (even limited devices like cell phones!) are capable of billions of floating-point operations per second. If that sort of speed greatly exceeds you "feasibility" requirement, then there are lots of alternatives that may be palatable, such as rational approximations, continued fractions, or software multi precision floating-point.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号