BS2sx Stamp won't perform division calculations
djkintexas
Posts: 4
in BASIC Stamp
I'm programming in PBasic 2.5
The stamp is a BS2sx
I can't get the stamp to perform division.
For example, the following code returns 0 value.
Debug DEC 50/3, CR
The stamp performs and outputs addition, subtraction, and multiplication perfectly.
Using actual decimal values or variables makes no difference.
Any ideas?
The stamp is a BS2sx
I can't get the stamp to perform division.
For example, the following code returns 0 value.
Debug DEC 50/3, CR
The stamp performs and outputs addition, subtraction, and multiplication perfectly.
Using actual decimal values or variables makes no difference.
Any ideas?
Comments
You can increase your resolution and do something like this
You must define value as a Word variable. Note that we've scaled it up by 10 so that we can derive a resolution of 10ths. This will print out 16.6 -- which is closer to 16.667 than 16.
-Phil
Either the OP has a bad chip or mis-observed.
In this line, DEBUG DEC value / value1, ".", DEC (value // value1) / 3, CR
Why divide (value // value1) by 3?
The line returns a value, but it isn't correct.
In my actual program, value is smaller than value1, so the answer is always less than 1.
Since the Stamp is limited in it's ability to perform mathematical calculations, would you recommend the propeller?
Thanks
The Propeller is also integer math, but with a lot of room to work using signed 31-bit values. And, if you want, you can use a floating point co-processor.
The Propeller opens up a whole host of features that one cannot match with a BASIC Stamp.
-Phil
Phil, I went through the change log, and it don't see that anything was deleted.
I may have to move to the propeller for this project since the stamp doesn't seem to handle this simple calculation.
I was hoping I could do this simple project with the Stamp. I've not figured out to get the propeller to cooperate with me at all.
I think all the posts are there. At least the ones I've seen.
Cut and paste your basic code so everyone can look at it.
You know, this entire thread is based on a false premise. Namely that returns the value 0. It does not. On my BS-2sx, it returns the value 16, just as expected. If it *does* return any other value, then the OP has a bad device.