DSPRelated.com
Forums

fixed point & floating point

Started by ranjeet September 3, 2004

Jerry Avins wrote:

> When taking Randy's suggestion, you will do well to rid yourself of some > misconceptions.
> Overflow can happen always when adding, and except for the Q format that > represents all numbers as smaller than one, when multiplying.
If the product form is the same as the multiplier and multiplicand, yes. Most processors multiply two N bit numbers generating a 2N bit product that cannot overflow. If one uses only some of the product bits, not including the most significant bit, then it might overflow. PL/I is one of the few high level languages with provision for scaled fixed point (either binary or decimal) numbers. Each variable can have its own scale factor. With the appropriate number of bits for the sum, it can't overflow either. -- glen
glen herrmannsfeldt wrote:

> > > Jerry Avins wrote: > >> When taking Randy's suggestion, you will do well to rid yourself of >> some misconceptions. > > >> Overflow can happen always when adding, and except for the Q format >> that represents all numbers as smaller than one, when multiplying. > > > If the product form is the same as the multiplier and multiplicand, yes. > > Most processors multiply two N bit numbers generating a 2N bit > product that cannot overflow. If one uses only some of the product > bits, not including the most significant bit, then it might overflow. > > PL/I is one of the few high level languages with provision for scaled > fixed point (either binary or decimal) numbers. Each variable can > have its own scale factor. > > With the appropriate number of bits for the sum, it can't overflow > either. > > -- glen >
Actually, a number of languages used to support scaled fixed point. It used to be in most languages aimed at technical uses, like defence and telecoms. It seems to have gone out of fashion, though. I can't think of any currently popular language which supports it. Ada maybe (it is popular in defence circles)? I can't remember any of the Ada I learned years ago. Regards, Steve
Steve Underwood wrote:

> glen herrmannsfeldt wrote: > >> >> >> Jerry Avins wrote: >> >>> When taking Randy's suggestion, you will do well to rid yourself of >>> some misconceptions. >> >> >> >>> Overflow can happen always when adding, and except for the Q format >>> that represents all numbers as smaller than one, when multiplying. >> >> >> >> If the product form is the same as the multiplier and multiplicand, yes. >> >> Most processors multiply two N bit numbers generating a 2N bit >> product that cannot overflow. If one uses only some of the product >> bits, not including the most significant bit, then it might overflow. >> >> PL/I is one of the few high level languages with provision for scaled >> fixed point (either binary or decimal) numbers. Each variable can >> have its own scale factor. >> >> With the appropriate number of bits for the sum, it can't overflow >> either. >> >> -- glen >> > Actually, a number of languages used to support scaled fixed point. It > used to be in most languages aimed at technical uses, like defence and > telecoms. It seems to have gone out of fashion, though. I can't think of > any currently popular language which supports it. Ada maybe (it is > popular in defence circles)? I can't remember any of the Ada I learned > years ago. > > Regards, > Steve
Several Forth packages intended for embedded systems. All Forths have a scaling operator, and some have more extensive suppport. -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Steve Underwood <steveu@dis.org> writes:
> [...] > I can't think of any currently popular language which supports it.
C++, if you write your own classes, complete with overloaded operators. Problem is, the language is a bit fat for resource-starved embedded systems (we're still working with 8K of RAM!). -- % Randy Yates % "Midnight, on the water... %% Fuquay-Varina, NC % I saw... the ocean's daughter." %%% 919-577-9882 % 'Can't Get It Out Of My Head' %%%% <yates@ieee.org> % *El Dorado*, Electric Light Orchestra http://home.earthlink.net/~yatescr
Randy Yates wrote:

> Steve Underwood <steveu@dis.org> writes: > >>[...] >>I can't think of any currently popular language which supports it. > > > C++, if you write your own classes, complete with overloaded operators. > Problem is, the language is a bit fat for resource-starved embedded > systems (we're still working with 8K of RAM!).
Check out http://forth.com/embedded/trial-system.html Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Jerry Avins <jya@ieee.org> writes:

> Randy Yates wrote: > >> Steve Underwood <steveu@dis.org> writes: >> >>>[...] >>>I can't think of any currently popular language which supports it. >> C++, if you write your own classes, complete with overloaded >> operators. >> Problem is, the language is a bit fat for resource-starved embedded >> systems (we're still working with 8K of RAM!). > > Check out http://forth.com/embedded/trial-system.html
From what I remember of Forth, it was assembly in reverse polish notation. Why not just learn assembly? -- % Randy Yates % "Though you ride on the wheels of tomorrow, %% Fuquay-Varina, NC % you still wander the fields of your %%% 919-577-9882 % sorrow." %%%% <yates@ieee.org> % '21st Century Man', *Time*, ELO http://home.earthlink.net/~yatescr
Randy Yates wrote:

> Jerry Avins <jya@ieee.org> writes: > > >>Randy Yates wrote: >> >> >>>Steve Underwood <steveu@dis.org> writes: >>> >>> >>>>[...] >>>>I can't think of any currently popular language which supports it. >>> >>>C++, if you write your own classes, complete with overloaded >>>operators. >>>Problem is, the language is a bit fat for resource-starved embedded >>>systems (we're still working with 8K of RAM!). >> >>Check out http://forth.com/embedded/trial-system.html > > > From what I remember of Forth, it was assembly in reverse polish > notation. Why not just learn assembly?
Forth is a lot more powerful than assembly. Some people call it a scripting language because of its ease of use. Others belittle it as a glorified macro assembler. It is what it is, and trying to peg it to one thing is much like the blind men describing the elephant. One thing it isn't is a marketable skill, but many turnkey houses that use it don't say so. When you have a good thing going, why encourage others to share? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Steve Underwood wrote:

> Actually, a number of languages used to support scaled fixed > point. It used to be in most languages aimed at technical uses, > like defence and telecoms. It seems to have gone out of fashion, > though. I can't think of any currently popular language which > supports it. Ada maybe (it is popular in defence circles)? I can't > remember any of the Ada I learned years ago. > > Regards, > Steve >
Are you aware of the similarities between Ada and VHDL? I guess if we talk fixed point and embedded systems, we're close to talking the language of FPGA designers, and that is VHDL. I see a trend to do more and more stuff in FPGAs instead of DSPs, usually either because they're faster or because they can be adapted better to the task, or just, because they're in place already. If others do it the same way, there'll be less need for fixed point support in other languages. Bernhard