The Stamps only do integer arithmetic. They don't do floating point, so values like 12.15 can't exist in a Stamp. Arithmetic like this is always done using scaled fixed point arithmetic where 12.15 is represented as the integer 1215 and appropriate scaling is done during calculations. It is possible to attach an external floating point processor to a Stamp if you really have to do floating point including transcendental functions: www.parallax.com/StoreSearchResults/tabid/768/txtSearch/fpu/List/0/SortField/4/ProductID/401/Default.aspx
Iam going to use stamp to do calculation on Peukert's Equation (Peukert's Law) used for calculating lead batteri. I need to calculate the load on the battries and the time left on current load. All of that includes logarithms. But I can work without decimals exept when the result is shown on the LCD. Let's say I got a value of 4560 but the trus valu I need to show on the lcd is 4.56. I can take 4560 / 1000 = 4.56 but as you say stamp cannot handle that so how do I do that?
The DIG operator allows you to extract individual digits from the decimal representation of an integer value. It's easy enough to do your own formatting inserting a decimal point as needed during output to the parallel LCD. It's easy on a serial LCD, but harder with a parallel LCD on a BS2 Stamp. The BS2p Stamps have built-in support for a parallel LCD including the same sort of formatting provided for SEROUT.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
http://www.emesys.com/BS2math3.htm#Logcalc
hope this helps.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Yepp there is more to it when that. All values are coming from Stamp so the correct thing is to write it like this Log(x/y).
I looked one this page http://owlogic.com/BS2math3.htm#Logcalc but my problem is how to enter a value ie 12.15? I can add 1215 but not 12.15!
B
www.parallax.com/StoreSearchResults/tabid/768/txtSearch/fpu/List/0/SortField/4/ProductID/401/Default.aspx
Here is an example, PBASIC calculation of dewpoint from temperature and relative humidity: www.emesystems.com/programs/dewpoint.bsx.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
B
a = 4560
SEROUT pin,Baud,[noparse][[/noparse]DEC a/1000,".",DEC3 a//1000] ' shows 4.560
SEROUT pin,Baud,[noparse][[/noparse]DEC a/1000,".",DEC2 (a//1000)/10] ' shows 4.56
B