Could I get a hand with simplifying some calculations in integer math? I would like to calculate some values to plug into simple digital filter code inside the actual assembler. The assembler supports integer variables of 32 bits precision. The idea is that the student can put in the actual values of the R and the C in a basic RC type low pass filter and the code will load the literal values appropriate for the digital simulation of that filter. I am working from this text: Let us take for example the Simple RC (resistor-capacitor) low pass filter. This circuit passes frequencies in the input voltage that are lower than some critical frequency (called the cutoff frequency) determined by the resistor and capacitor values, while severely attenuating any higher frequencies. The output voltage Vout, then, is simply a selectively reduced version of Vin (input voltage). The resistor drops the output voltage, as does the voltage that goes into charging C. At first, Vout = a * Vin (where the constant a is the amount of attenuation caused by R and C). It can be shown that a=1/RC (where R is in ohms and C is in farads). The voltage change with time across a capacitor is an exponential function. If the voltage at time zero is V, then the voltage at time t is given by Ve^(-at) (a is the Same constant as above). I need to find e^(-at) given the value of at. I can find at pretty easy: Since t=1 (ms, sec, usec, etc...) at is 1/RC expressed as a fraction of 256. So for example, the current code has a section like this at EQU 256* 360000/1000000 movlw at ;for a digital equivalent to an RC filter with a ;360kOhm resistor and a 1uF capacitor And that puts 92 (hex 5C) into w just dandy. E^(-at) is the same as (1/e) ^ (at) right? Now, 1/e is approximately 368/1000 and so I can calculate a power by making a macro in the assembler that multiplies that value times itself (at) times and then take that time 256 divided by 1000. The value (at) can not be more than 255/256 and probably will not be more than about 192/256. 368^192 exceeds 32 bits by a little tiny bit. I guess the question is: How does one calculate a fractional power to any degree of accuracy in 32 bit integer math? --- James Newton, massmind.org Knowledge Archiver james@massmind.org 1-619-652-0593 fax:1-208-279-8767 All the engineering secrets worth knowing: http://techref.massmind.org What do YOU know? -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist