Hi Peter. Peter wrote: > > You can think of your numbers as fixed point. This implies especially > that the precision is limited. So to convert, you can figure in a fixed > multiplier, eg: > > xx.yy = 0XXYY/100 -> you store 0XXYY 2 > xxx.yy = XXXYY/100 -> you store XXXYY 2 > xx = 0XX00/100 -> you store 0XX00 0 > x.y = 00XY0/100 -> you store 00XY0 1 Isn't that supposed to be ( last two ) xx = 000XX/100 -> you store 000XX 0 x.y = 000XY/100 -> you store 000XY 1 Or in your terms xx = 0XX00/100 -> you store 0XX00 2 x.y = 00XY0/100 -> you store 00XY0 2 Dmitriy. > thus the decimal point 'disappears' for internal conversion and > comparison purposes (you store 0XXYY), but you store is away and use it > later for display. You have to store the requested precision (number of > digits after . entered) along with the encoded request. Then when you > display a number you do: > > 0XXYY 1 -> zXX.Y > > z is a suppressed leading zero, XX are the integer part, you print a dot > iff the original string had a dot, and as many Y's as Y's were in the > original string after the dot (and suppress the others). > > To store and compare data easily in internal form you can use the binary > form of XXXYY. Multiplying binary values by d'100' is easy (as long as > you do not ever need to divide). If you have enough storage you can use > the decimal form (f.ex. unpacked BCD) for arithmetics. This makes for > low cost conversion for display on multiplier-less micros. > > I hope that this makes sense. It's 3AM here. > > Peter -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist