Hello Tamas, At 23.06 2008.07.14, you wrote: >I think we have to find out what OP wanted to say from the equations, which >was: > >> out=(adc-min)*65536/(max-min); > >So I guess max-min could be less or greater than 65536, but even then the >number have to be evenly scaled over the full 16bit range, right? I already knew how to get max precision from just 32bit division, what I asked was if anybody had multiprecision / extendedprecision routines to share (here I am rephrasing), which is the only way to compute without approximations out=(adc-min)*65536/(max-min) >Multiply by 2^16 is equal to shift by 16 bits, so the storage needed from >the 24 bits is 24+16 bit, which is 40. You have 32 and 64 bit sizes >supported by C30 so I guess you have no other choice than use 64 bit. But I >think you would need to cast at least the constant to 64bit number to make >sure it will use that: > >out=(adc-min)*(unsigned long long)65536/(max-min); > >or > >out=(adc-min)*65536ULL/(max-min); yes, in fact I have specified that was pseudo C, and anyway my target was assembly (DIV and MUL were mentioned). Anyhow, it doesn't matter, I got acceptable precison, but a library with signed and unsigned 64bit/32bit division and 32bit*32bit=64bit multiplication would still be handy. I'm very new to the dsPIC. With kind regards, Mario > >whichever way you like. > >Tamas > > > > >On Mon, Jul 14, 2008 at 8:18 PM, Olin Lathrop >wrote: > >> Electron wrote: >> > I received many answers (for which I'm grateful), but none addressed >> > my request, although I think was quite clear. >> >> If everyone mistunderstood the question, just maybe you should consider the >> question was poorly worded. >> >> I still don't understand how this isn't just a scaling problem after a >> subtraction. >> >> > However, I've done my math and by maximixing precision (shifting left >> > the data >> > before division to get maximum precision even from 32bit), I've been >> > able to make >> > it work satisfactorily with 32bit math. >> >> Sounds exactly like one of the suggestions I made. I guess my answer >> wasn't >> clear enough. >> >> >> ******************************************************************** >> Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products >> (978) 742-9014. Gold level PIC consultants since 2000. >> -- >> http://www.piclist.com PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist >> > > > >-- >Rudonix DoubleSaver >http://www.rudonix.com >-- >http://www.piclist.com PIC/SX FAQ & list archive >View/change your membership options at >http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist