Floating point math
Archiver
Posts: 46,084
Paul,
If I ask the stamp to perform the following math:
x=4/3
does the stamp carry the value 1.333 in memory when doing subsequent math?
What would the result of y = x * 3
Will the answer to y be 3 or 4.
As always, thanks for the help
Dave cousins
--- Paul Verhage <pverhage@s...> wrote:
> I don't think you can. You're trying to use a floating point exponent.
> Basic Stamps can't do floating point.
>
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
If I ask the stamp to perform the following math:
x=4/3
does the stamp carry the value 1.333 in memory when doing subsequent math?
What would the result of y = x * 3
Will the answer to y be 3 or 4.
As always, thanks for the help
Dave cousins
--- Paul Verhage <pverhage@s...> wrote:
> I don't think you can. You're trying to use a floating point exponent.
> Basic Stamps can't do floating point.
>
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
Comments
x=4/3 ' x=1
y=x*3 ' y=3
You'd need to scale for decimal points as I mentioned in my earlier message
(fixed-point math) or add a PAK-I or PAK-II.
Regards,
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: david cousins [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=RdlbYphhMPBFOgEu5Be5T8nnBY-uS8ccpEFwBk98czxolNJf84NHgeTBBrPpVg7q3KakoXID_ITW]cuz_hsv@y...[/url
> Sent: Thursday, April 05, 2001 3:08 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] FLOATING POINT MATH
>
>
> Paul,
> If I ask the stamp to perform the following math:
> x=4/3
> does the stamp carry the value 1.333 in memory when doing
> subsequent math?
> What would the result of y = x * 3
> Will the answer to y be 3 or 4.
> As always, thanks for the help
> Dave cousins
>
> --- Paul Verhage <pverhage@s...> wrote:
> > I don't think you can. You're trying to use a floating point exponent.
> > Basic Stamps can't do floating point.
> >
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>x=4/3
>does the stamp carry the value 1.333 in memory when doing subsequent math?
>What would the result of y = x * 3
>Will the answer to y be 3 or 4.
>As always, thanks for the help
>Dave cousins
In integer math, 4/3*3=3.
But if you do it as x=4000/3, it will carry it along as 1333.
Do-it-yourself fixed point math.
>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.
I have a couple of logarithm techniques here:
http://www.emesys.com/BS2math3.htm
What is your range of x, and the required accuracy? Since the
exponent is close to 1.0, you might get by with a couple of terms in
a power series.
-- best regards
Thomas Tracy Allen PhD
electronically monitored ecosystems
http://www.emesystems.com
mailto:tracy@e...