Float32 f.exp
bunkerush5
Posts: 10
The rangefinder I am using for a project is connected to an ADC and I need to use the equation below to get the proper range values from the ADC. There is little documentation for float32 especially the exp.
my equation is dist=66.928e^(-0.01*ADC value)
obj
f: "float32"
pub
f.start
f.exp( this is where I am lost)
Do I need to do just the e^( ) portion and save that as one variable and then multiply that by the 66.928 and do everything in pieces or can I do it all as one?
I would appreciate any help with the equation.
Thanks
my equation is dist=66.928e^(-0.01*ADC value)
obj
f: "float32"
pub
f.start
f.exp( this is where I am lost)
Do I need to do just the e^( ) portion and save that as one variable and then multiply that by the 66.928 and do everything in pieces or can I do it all as one?
I would appreciate any help with the equation.
Thanks
Comments
untested, getADC returns an integer
[code]
r := f.fround(f.fmul(66.928, f.exp(f.fmul(-0.01, f.ffloat(getADC)))))
'or
r := f.fmul(66.928, f.exp(f.fmul(-0.01, f.ffloat(getADC))))
r:=f.fround(r)
I get 1.401299e-44 and I am expecting a value from 6-48 depending on the adc value. Is there a way to only show 1 decimal? Without the rounding function I get 10.27675 at a set range.