Exponet on BS2 !! ?
Archiver
Posts: 46,084
How would you do this:
X^(-0.938) (where ^ is 'raised to' and not 'or')
on the BS2 ??
I have had no luck getting the ^ part.
thanks!
Mike,
X^(-0.938) (where ^ is 'raised to' and not 'or')
on the BS2 ??
I have had no luck getting the ^ part.
thanks!
Mike,
Comments
Basic Stamps can't do floating point.
You could do something like X^2 or X^3
Paul
>
Original Message
> From: Mike [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=BFx5psmRVnJm0iCrIW7HlE3Z0PA-9X3K472oN0nFLt9IoxIW_JcSq5hQsVFfi1zr1aJl_-hV]silo@c...[/url
> Sent: Thursday, April 05, 2001 1:20 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Exponet on BS2 !! ?
>
>
> How would you do this:
>
> X^(-0.938) (where ^ is 'raised to' and not 'or')
>
> on the BS2 ??
>
> I have had no luck getting the ^ part.
>
>
> thanks!
>
> Mike,
>
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
Original Message
> How would you do this:
>
> X^(-0.938) (where ^ is 'raised to' and not 'or')
>
> on the BS2 ??
>
> I have had no luck getting the ^ part.
address below.
You can do this with logarithm tables, but with integer math it doesn't make
a lot of sense to do so.
Al Williams
AWC
*Floating point math for the Stamp, PIC, SX, or any microcontroller:
http://www.al-williams.com/awce/pak1.htm
>
Original Message
> From: Mike [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=qJWOD9eQpgUSsJzocSpJKWQL3aX_RvWWCrHp16ePEOXJJqYJkRmRmVoFxyzBL6lTnH4wQ1n9aw]silo@c...[/url
> Sent: Thursday, April 05, 2001 2:20 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Exponet on BS2 !! ?
>
>
> How would you do this:
>
> X^(-0.938) (where ^ is 'raised to' and not 'or')
>
> on the BS2 ??
>
> I have had no luck getting the ^ part.
>
>
> thanks!
>
> Mike,
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
(c) 2000 by CMP Books, ISBN: 1-929629-09-5. Along with other topics, he
treats logarithms and exponentials on integer-based processors. In any
case, his book is a fascinating read.
Regards,
Daniel McGlothin
Original Message
From: Mike [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=NxsMFsVUFuAdVnrewoDg3gnXMMIMU6u8fSrm2dwomFijXjBCapA55zTMDCh0OWxNTx00SfkUSQY]silo@c...[/url
Sent: Thursday, April 05, 2001 3:20 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Exponet on BS2 !! ?
How would you do this:
X^(-0.938) (where ^ is 'raised to' and not 'or')
on the BS2 ??
I have had no luck getting the ^ part.
thanks!
Mike,
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>(c) 2000 by CMP Books, ISBN: 1-929629-09-5. Along with other topics, he
>treats logarithms and exponentials on integer-based processors. In any
>case, his book is a fascinating read.
>
>Regards,
>Daniel McGlothin
Hi Daniel,
I agree that Crenshaw's book is really good. But there is not really
much there for integer processors on the level of the BASIC Stamp.
The book mostly assumes that your processor can do floating point as
a basis for the higher functions. He favors _clever_ use of
convergent series.
For logs and exponentials, the exception is his integer bitlog
function. I put a BS2 implementation of that on my Web page at
http://www.emesys.com/BS2math3.htm
I see that there is no reference to bitlog in my index at the top of
the page, but the material comes before the stuff on other ways to do
the logarithm. The page also has a numerical (not power series)
approach that comes from Donald Knuth's book.
I was surprised that there is nothing about CORDIC algorithms in
Crenshaw's book, surprising because that is the approach used by
practically every good calculator in existence. (Including Al's
PAKs) Al turned me on to the power of the CORDICs.
-- best regards
Tracy Allen
electronically monitored ecosystems
http://www.emesystems.com
mailto:tracy@e...
bitlog, I enjoyed the story of his "discovery" as much as the function
itself. It reminds me that I'm glad for the giants who have went before,
giving us things such as math libraries.
Regards,
Daniel McGlothin
> For logs and exponentials, the exception is his integer bitlog
> function. I put a BS2 implementation of that on my Web page at
> http://www.emesys.com/BS2math3.htm
> I see that there is no reference to bitlog in my index at the top of
> the page, but the material comes before the stuff on other ways to do
> the logarithm.
> From: "Mike" <silo@c...>
>
> How would you do this:
> X^(-0.938) (where ^ is 'raised to' and not 'or')
> on the BS2 ??
I would dust off the old calculus 101
book and try a Taylor expansion:
f(x)=f(a) + (x-a)*f'(a)/1! + (x-a)^2*f''(a)/2! + .....
where f'(a) is the derivative of f(x) at x=a, etc.
I would try expanding f(x)=x^0.062 around a=1
since x^(-0.938)=(x^0.062)/x. Two or three terms
might be enough depending on the
accuracy and range you require.
You might want to scale the fractions up by 256
and use the */ scaling multiplier. It will
be tricky to avoid overflows!
The boring details are
"left as an exercise for the student" ;-)
Ciao,
Dave
The Cheap Seismometer Project
http://www.infiltec.com/seismo/