Hi There, Is it common practise to denote the format of a fixed-point number as s/u [x.y], where x is the number of non-fractional bits, y is the number of fractional bits and s is denoting signed values and u unsigned values? If this is the case, how would I represent a fraction like 0.02 (unsigned) in an 8-bit fixed-point format and what format would be "optimal" i.e., preserve the most information? Could one use another format that would "preserve" more "precision" than the [0.8] format? Something like a [-5.13] format? Any comments and or suggestions would be greatly appreciated, Jaco Versfeld
Fixed-point formats
Started by ●October 1, 2007
Reply by ●October 1, 20072007-10-01
jaco.versfeld@gmail.com wrote:> Hi There, > > Is it common practise to denote the format of a fixed-point number as > s/u [x.y], where x is the number of non-fractional bits, y is the > number of fractional bits and s is denoting signed values and u > unsigned values?As far as I know, that's the most common way. Another interprets x as the total number of bits, including sign if any.> If this is the case, how would I represent a fraction like 0.02 > (unsigned) in an 8-bit fixed-point format and what format would be > "optimal" i.e., preserve the most information? Could one use another > format that would "preserve" more "precision" than the [0.8] format? > Something like a [-5.13] format?You need to consider the whole range of numbers. Engineering involves compromise. If .02 is the only number that ever needs to be represented, a single bit will do. Jerry -- Engineering is the art of making what you want from things you can get. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply by ●October 1, 20072007-10-01
jaco.versfeld@gmail.com writes:> Hi There, > > Is it common practise to denote the format of a fixed-point number as > s/u [x.y], where x is the number of non-fractional bits, y is the > number of fractional bits and s is denoting signed values and u > unsigned values? > > If this is the case, how would I represent a fraction like 0.02 > (unsigned) in an 8-bit fixed-point format and what format would be > "optimal" i.e., preserve the most information? Could one use another > format that would "preserve" more "precision" than the [0.8] format? > Something like a [-5.13] format? > > Any comments and or suggestions would be greatly appreciated, > Jaco VersfeldJaco, I haven't seen a practice that's widespread enough to call it "common." I use the notation X(a,b) where X is A or U in my documents and programs, which I got from working with a guy at Lincoln Labs in some defense work. (See http://www.digitalsignallabs.com/fp.pdf). I've seen the Q notation quite a bit (e.g., Q(15), which would mean x = X/2^15, where X is the integer value and x is the fixed-point value). To be honest, that is probably just as useful as my A(0,15) format. I used to work with a guy from Sony Ericsson that used a complex format in which there was a notation for all unused bits on the left, on the right, all 1 bits, 0 bits, etc., as well as the actual binary point. So I think it's a free-for-all. -- % Randy Yates % "And all that I can do %% Fuquay-Varina, NC % is say I'm sorry, %%% 919-577-9882 % that's the way it goes..." %%%% <yates@ieee.org> % Getting To The Point', *Balance of Power*, ELO http://www.digitalsignallabs.com
Reply by ●October 1, 20072007-10-01
Randy Yates wrote:> jaco.versfeld@gmail.com writes: > >> Hi There, >> >> Is it common practise to denote the format of a fixed-point number as >> s/u [x.y], where x is the number of non-fractional bits, y is the >> number of fractional bits and s is denoting signed values and u >> unsigned values? >> >> If this is the case, how would I represent a fraction like 0.02 >> (unsigned) in an 8-bit fixed-point format and what format would be >> "optimal" i.e., preserve the most information? Could one use another >> format that would "preserve" more "precision" than the [0.8] format? >> Something like a [-5.13] format? >> >> Any comments and or suggestions would be greatly appreciated, >> Jaco Versfeld > > Jaco, > > I haven't seen a practice that's widespread enough to call it "common." > > I use the notation X(a,b) where X is A or U in my documents and programs, > which I got from working with a guy at Lincoln Labs in some defense work. > (See http://www.digitalsignallabs.com/fp.pdf). > > I've seen the Q notation quite a bit (e.g., Q(15), which would mean > x = X/2^15, where X is the integer value and x is the fixed-point value). > To be honest, that is probably just as useful as my A(0,15) format. > > I used to work with a guy from Sony Ericsson that used a complex format > in which there was a notation for all unused bits on the left, on the > right, all 1 bits, 0 bits, etc., as well as the actual binary point. > > So I think it's a free-for-all.What I've seen matches what Randy has said. In my book (see my tag line) I use IrQ notation, e.g. a "pure fractional" signed 16-bit number is 1r15, where the sign bit has a weight of 1, and there are 15 bits with fractional weights -- note that in the notation that I used there's no indication of sign. I think Randy's notation works better, and may adopt it (or try to improve it) if I go to a second edition. The bottom line is that if you are writing something you need to explain your notation, and if you are reading something you need to make _absolutely_ sure that you understand the notation. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html
Reply by ●October 1, 20072007-10-01
Jerry Avins wrote:> jaco.versfeld@gmail.com wrote:>> Is it common practise to denote the format of a fixed-point number as >> s/u [x.y], where x is the number of non-fractional bits, y is the >> number of fractional bits and s is denoting signed values and u >> unsigned values?> As far as I know, that's the most common way. Another interprets x as > the total number of bits, including sign if any.PL/I uses the total digits excluding the sign, and the number after the radix point (either binary or decimal). The number of digits after the decimal point may be negative or more than the precision (number of significant digits).>> If this is the case, how would I represent a fraction like 0.02 >> (unsigned) in an 8-bit fixed-point format and what format would be >> "optimal" i.e., preserve the most information? Could one use another >> format that would "preserve" more "precision" than the [0.8] format? >> Something like a [-5.13] format?> You need to consider the whole range of numbers. Engineering involves > compromise. If .02 is the only number that ever needs to be represented, > a single bit will do.If you know the range that will ever need to be represented, then you can find the best way to represent that. In many cases you know that the range won't exceed 1, and often that it can be approximated with a value slightly less than one. Otherwise, it is often a tradeoff, and one tries to balance between range and precision(*). (*) precision is a complicated word. It is even worse in a problem like this. I am hoping not to start a discussion on the meaning of precision. -- glen
Reply by ●October 1, 20072007-10-01
glen herrmannsfeldt wrote:> Jerry Avins wrote: > >> jaco.versfeld@gmail.com wrote: > >>> Is it common practise to denote the format of a fixed-point number as >>> s/u [x.y], where x is the number of non-fractional bits, y is the >>> number of fractional bits and s is denoting signed values and u >>> unsigned values? > >> As far as I know, that's the most common way. Another interprets x as >> the total number of bits, including sign if any. > > PL/I uses the total digits excluding the sign, and the number after the > radix point (either binary or decimal). The number of digits > after the decimal point may be negative or more than the precision > (number of significant digits). > >>> If this is the case, how would I represent a fraction like 0.02 >>> (unsigned) in an 8-bit fixed-point format and what format would be >>> "optimal" i.e., preserve the most information? Could one use another >>> format that would "preserve" more "precision" than the [0.8] format? >>> Something like a [-5.13] format? > >> You need to consider the whole range of numbers. Engineering involves >> compromise. If .02 is the only number that ever needs to be >> represented, a single bit will do. > > If you know the range that will ever need to be represented, then you > can find the best way to represent that. In many cases you know that > the range won't exceed 1, and often that it can be approximated with > a value slightly less than one. Otherwise, it is often a tradeoff, > and one tries to balance between range and precision(*). > > (*) precision is a complicated word. It is even worse in a > problem like this. I am hoping not to start a discussion on the > meaning of precision. > > -- glen >Not to neglect accuracy, repeatability and resolution. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html
Reply by ●October 1, 20072007-10-01
On Oct 1, 8:12 am, jaco.versf...@gmail.com wrote:> Hi There, > > Is it common practise to denote the format of a fixed-point number as > s/u [x.y], where x is the number of non-fractional bits, y is the > number of fractional bits and s is denoting signed values and u > unsigned values? > > If this is the case, how would I represent a fraction like 0.02 > (unsigned) in an 8-bit fixed-point format and what format would be > "optimal" i.e., preserve the most information? Could one use another > format that would "preserve" more "precision" than the [0.8] format? > Something like a [-5.13] format?sure, why not. you can use any fixed scaling factor you want (but you must remember it and account for it when mutliplications and divisions are done). increasing it will increase precision, but decrease the range. that's the tradeoff you must accept with fixed-point. r b-j
Reply by ●October 1, 20072007-10-01
glen herrmannsfeldt wrote: ...> If you know the range that will ever need to be represented, then you > can find the best way to represent that. In many cases you know that > the range won't exceed 1, and often that it can be approximated with > a value slightly less than one. Otherwise, it is often a tradeoff, > and one tries to balance between range and precision(*).How is > 1 fundamentally different from less than >2 or >1/2? Whatever the range, you get to slice it up into 256 discrete values.> (*) precision is a complicated word. It is even worse in a > problem like this. I am hoping not to start a discussion on the > meaning of precision.Amen! Jerry -- Engineering is the art of making what you want from things you can get. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply by ●October 1, 20072007-10-01
On Oct 1, 8:12 am, jaco.versf...@gmail.com wrote:> Hi There, > > Is it common practise to denote the format of a fixed-point number as > s/u [x.y], where x is the number of non-fractional bits, y is the > number of fractional bits and s is denoting signed values and u > unsigned values? > > If this is the case, how would I represent a fraction like 0.02 > (unsigned) in an 8-bit fixed-point format and what format would be > "optimal" i.e., preserve the most information? Could one use another > format that would "preserve" more "precision" than the [0.8] format? > Something like a [-5.13] format? > > Any comments and or suggestions would be greatly appreciated, > Jaco VersfeldYes that a common way. For a given word length, I use a simplier Bx notation were x represents the number of nonfractional bits (y is therefore implied and not needed), it works for me.
Reply by ●October 2, 20072007-10-02
Jerry Avins wrote: (snip on fixed point values with the binary point shifted)> How is > 1 fundamentally different from less than >2 or >1/2? Whatever > the range, you get to slice it up into 256 discrete values.I would say that 1 is different, but, yes, if you have another known maximum value that is fine. Many normalization methods naturally give a result with a maximum of one. If you multiply two values with a maximum of one the product still has a maximum of one. That isn't true of the others you mention. -- glen






