Fun With Fractions -- BASIC Stamp Style
Archiver
Posts: 46,084
The topic of fractions comes up from time-to-time, so I'm just going to
do a *quickie* here to help those that aren't familiar with the BASIC
Stamp's */ (star-slash) and ** (star-star) operators. Before I give
examples, please GOTO and bookmark this web page:
http://www.emesystems.com/BS2math1.htm
For my money, the best BASIC Stamp page on the Internet belongs to my
buddy, Tracy Allen. If you want to know hard-core BASIC Stamp stuff,
there is a really good possibility that Tracy knows it and has published
it on his site.
Okay, multiplying by fractions on the BASIC Stamp. Yes, it can be done
... but the result will still be an integer. Tracy's page shows how to
deal with this at various levels of precision.
1) */
The star-slash operator let's you multiply by a fractional value less
than 256 (I'm not going into details here, just showing you how). To
use */, it's just a matter of multiplying your FP value by 256. Let's
say, for example, you want to multiply something by Pi:
3.14159 * 256 = 804
Now you can use it like this:
area = (radius * radius) */ 804
If the radius value is 4, the area will be calculated as 50 by the BASIC
Stamp; 50.2655 by my HP calculator. You can do tricks like multiplying
by 31.4169 (*/ 8042), but there are concerns and Tracy's information on
*/ and ** show how to avoid problems when attempting to increase
precision.
2) **
Let's you multiply by fractional values less than 1. To use **,
multiply your fraction by 65536. In a message that prompted this,
someone was looking for a way to find 1.5% of a 16-bit value.
0.015 * 983
To use:
error = reading ** 983
Again, the purpose of this message was to show you a quick "how to" --
not to go into details. Please do yourself a favor and grab your
favorite beverage, make sure you're not disturbed, and go visit Tracy's
web site. On Tracy's site, the rubber hits the road as he actually uses
BASIC Stamps in very demanding applications. Between his design
requirements and incredible intellect, he's come up with some very neat
stuff and I often turn to his web site for guidance.
-- Jon Williams
-- Parallax
[noparse][[/noparse]Non-text portions of this message have been removed]
do a *quickie* here to help those that aren't familiar with the BASIC
Stamp's */ (star-slash) and ** (star-star) operators. Before I give
examples, please GOTO and bookmark this web page:
http://www.emesystems.com/BS2math1.htm
For my money, the best BASIC Stamp page on the Internet belongs to my
buddy, Tracy Allen. If you want to know hard-core BASIC Stamp stuff,
there is a really good possibility that Tracy knows it and has published
it on his site.
Okay, multiplying by fractions on the BASIC Stamp. Yes, it can be done
... but the result will still be an integer. Tracy's page shows how to
deal with this at various levels of precision.
1) */
The star-slash operator let's you multiply by a fractional value less
than 256 (I'm not going into details here, just showing you how). To
use */, it's just a matter of multiplying your FP value by 256. Let's
say, for example, you want to multiply something by Pi:
3.14159 * 256 = 804
Now you can use it like this:
area = (radius * radius) */ 804
If the radius value is 4, the area will be calculated as 50 by the BASIC
Stamp; 50.2655 by my HP calculator. You can do tricks like multiplying
by 31.4169 (*/ 8042), but there are concerns and Tracy's information on
*/ and ** show how to avoid problems when attempting to increase
precision.
2) **
Let's you multiply by fractional values less than 1. To use **,
multiply your fraction by 65536. In a message that prompted this,
someone was looking for a way to find 1.5% of a 16-bit value.
0.015 * 983
To use:
error = reading ** 983
Again, the purpose of this message was to show you a quick "how to" --
not to go into details. Please do yourself a favor and grab your
favorite beverage, make sure you're not disturbed, and go visit Tracy's
web site. On Tracy's site, the rubber hits the road as he actually uses
BASIC Stamps in very demanding applications. Between his design
requirements and incredible intellect, he's come up with some very neat
stuff and I often turn to his web site for guidance.
-- Jon Williams
-- Parallax
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
should be:
0.015 * 65536 = 983
Sorry for the confusion.
-- Jon Williams
-- Parallax
Original Message
From: Jon Williams
Sent: Tuesday, July 15, 2003 3:14 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Fun With Fractions -- BASIC Stamp Style
The topic of fractions comes up from time-to-time, so I'm just going to
do a *quickie* here to help those that aren't familiar with the BASIC
Stamp's */ (star-slash) and ** (star-star) operators. Before I give
examples, please GOTO and bookmark this web page:
http://www.emesystems.com/BS2math1.htm
For my money, the best BASIC Stamp page on the Internet belongs to my
buddy, Tracy Allen. If you want to know hard-core BASIC Stamp stuff,
there is a really good possibility that Tracy knows it and has published
it on his site.
Okay, multiplying by fractions on the BASIC Stamp. Yes, it can be done
... but the result will still be an integer. Tracy's page shows how to
deal with this at various levels of precision.
1) */
The star-slash operator let's you multiply by a fractional value less
than 256 (I'm not going into details here, just showing you how). To
use */, it's just a matter of multiplying your FP value by 256. Let's
say, for example, you want to multiply something by Pi:
3.14159 * 256 = 804
Now you can use it like this:
area = (radius * radius) */ 804
If the radius value is 4, the area will be calculated as 50 by the BASIC
Stamp; 50.2655 by my HP calculator. You can do tricks like multiplying
by 31.4169 (*/ 8042), but there are concerns and Tracy's information on
*/ and ** show how to avoid problems when attempting to increase
precision.
2) **
Let's you multiply by fractional values less than 1. To use **,
multiply your fraction by 65536. In a message that prompted this,
someone was looking for a way to find 1.5% of a 16-bit value.
0.015 * 983
To use:
error = reading ** 983
Again, the purpose of this message was to show you a quick "how to" --
not to go into details. Please do yourself a favor and grab your
favorite beverage, make sure you're not disturbed, and go visit Tracy's
web site. On Tracy's site, the rubber hits the road as he actually uses
BASIC Stamps in very demanding applications. Between his design
requirements and incredible intellect, he's come up with some very neat
stuff and I often turn to his web site for guidance.
-- Jon Williams
-- Parallax
[noparse][[/noparse]Non-text portions of this message have been removed]
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
How do you use 65536 in this example ?
Doesnt that = 0 ?
Cheers,
Chris
Original Message
From: "Jon Williams" <jwilliams@p...>
To: <basicstamps@yahoogroups.com>
Sent: Wednesday, July 16, 2003 5:28 AM
Subject: RE: [noparse][[/noparse]basicstamps] Fun With Fractions -- BASIC Stamp Style
> Oops ... let me correct myself. I made an error in section 2. It
> should be:
>
> 0.015 * 65536 = 983
>
> Sorry for the confusion.
>
> -- Jon Williams
> -- Parallax
>
>
>
Original Message
> From: Jon Williams
> Sent: Tuesday, July 15, 2003 3:14 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Fun With Fractions -- BASIC Stamp Style
>
>
> The topic of fractions comes up from time-to-time, so I'm just going to
> do a *quickie* here to help those that aren't familiar with the BASIC
> Stamp's */ (star-slash) and ** (star-star) operators. Before I give
> examples, please GOTO and bookmark this web page:
>
> http://www.emesystems.com/BS2math1.htm
>
> For my money, the best BASIC Stamp page on the Internet belongs to my
> buddy, Tracy Allen. If you want to know hard-core BASIC Stamp stuff,
> there is a really good possibility that Tracy knows it and has published
> it on his site.
>
> Okay, multiplying by fractions on the BASIC Stamp. Yes, it can be done
> ... but the result will still be an integer. Tracy's page shows how to
> deal with this at various levels of precision.
>
> 1) */
>
> The star-slash operator let's you multiply by a fractional value less
> than 256 (I'm not going into details here, just showing you how). To
> use */, it's just a matter of multiplying your FP value by 256. Let's
> say, for example, you want to multiply something by Pi:
>
> 3.14159 * 256 = 804
>
> Now you can use it like this:
>
> area = (radius * radius) */ 804
>
> If the radius value is 4, the area will be calculated as 50 by the BASIC
> Stamp; 50.2655 by my HP calculator. You can do tricks like multiplying
> by 31.4169 (*/ 8042), but there are concerns and Tracy's information on
> */ and ** show how to avoid problems when attempting to increase
> precision.
>
>
> 2) **
>
> Let's you multiply by fractional values less than 1. To use **,
> multiply your fraction by 65536. In a message that prompted this,
> someone was looking for a way to find 1.5% of a 16-bit value.
>
> 0.015 * 983
>
> To use:
>
> error = reading ** 983
>
>
> Again, the purpose of this message was to show you a quick "how to" --
> not to go into details. Please do yourself a favor and grab your
> favorite beverage, make sure you're not disturbed, and go visit Tracy's
> web site. On Tracy's site, the rubber hits the road as he actually uses
> BASIC Stamps in very demanding applications. Between his design
> requirements and incredible intellect, he's come up with some very neat
> stuff and I often turn to his web site for guidance.
>
> -- Jon Williams
> -- Parallax
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
> This message has been scanned by WebShield. Please report SPAM to
> abuse@p....
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
parameter used with the ** operator -- it is not BASIC Stamp code. To
use this value, you would do this:
error = someValue ** 983 ' multiply someValue by 0.015
-- Jon Williams
-- Parallax
Original Message
From: Chris Anderson [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=qD2DJ9vdJk8js7pEkbVEHnmMMKpnMrMUf56VVuXXKX6FYIuF5tZq4WQHmJKs16_5yhPzdrrLMDtwY6mbRg]fuel@b...[/url
Sent: Tuesday, July 15, 2003 5:32 PM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] Fun With Fractions -- BASIC Stamp Style
Hey Jon,
How do you use 65536 in this example ?
Doesnt that = 0 ?
Cheers,
Chris
Original Message
From: "Jon Williams" <jwilliams@p...>
To: <basicstamps@yahoogroups.com>
Sent: Wednesday, July 16, 2003 5:28 AM
Subject: RE: [noparse][[/noparse]basicstamps] Fun With Fractions -- BASIC Stamp Style
> Oops ... let me correct myself. I made an error in section 2. It
> should be:
>
> 0.015 * 65536 = 983
>
> Sorry for the confusion.
>
> -- Jon Williams
> -- Parallax
>
>
>
Original Message
> From: Jon Williams
> Sent: Tuesday, July 15, 2003 3:14 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Fun With Fractions -- BASIC Stamp Style
>
>
> The topic of fractions comes up from time-to-time, so I'm just going
> to do a *quickie* here to help those that aren't familiar with the
> BASIC Stamp's */ (star-slash) and ** (star-star) operators. Before I
> give examples, please GOTO and bookmark this web page:
>
> http://www.emesystems.com/BS2math1.htm
>
> For my money, the best BASIC Stamp page on the Internet belongs to my
> buddy, Tracy Allen. If you want to know hard-core BASIC Stamp stuff,
> there is a really good possibility that Tracy knows it and has
> published it on his site.
>
> Okay, multiplying by fractions on the BASIC Stamp. Yes, it can be
> done ... but the result will still be an integer. Tracy's page shows
> how to deal with this at various levels of precision.
>
> 1) */
>
> The star-slash operator let's you multiply by a fractional value less
> than 256 (I'm not going into details here, just showing you how). To
> use */, it's just a matter of multiplying your FP value by 256. Let's
> say, for example, you want to multiply something by Pi:
>
> 3.14159 * 256 = 804
>
> Now you can use it like this:
>
> area = (radius * radius) */ 804
>
> If the radius value is 4, the area will be calculated as 50 by the
> BASIC Stamp; 50.2655 by my HP calculator. You can do tricks like
> multiplying by 31.4169 (*/ 8042), but there are concerns and Tracy's
> information on */ and ** show how to avoid problems when attempting to
> increase precision.
>
>
> 2) **
>
> Let's you multiply by fractional values less than 1. To use **,
> multiply your fraction by 65536. In a message that prompted this,
> someone was looking for a way to find 1.5% of a 16-bit value.
>
> 0.015 * 983
>
> To use:
>
> error = reading ** 983
>
>
> Again, the purpose of this message was to show you a quick "how to" --
> not to go into details. Please do yourself a favor and grab your
> favorite beverage, make sure you're not disturbed, and go visit
> Tracy's web site. On Tracy's site, the rubber hits the road as he
> actually uses BASIC Stamps in very demanding applications. Between
> his design requirements and incredible intellect, he's come up with
> some very neat stuff and I often turn to his web site for guidance.
>
> -- Jon Williams
> -- Parallax
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
> This message has been scanned by WebShield. Please report SPAM to
> abuse@p....
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject
> and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....