There are several different ways to do what you want. The place to look for a detailed explanation and examples is in the BASIC Stamp Syntax and Reference Manual or in the help files of the Stamp Editor.
There's an operator DIG used to provide a decimal digit of the decimal representation of a number.
There's what's called the DEC formatter used in a variety of I/O statements including SERIN, SEROUT, DEBUG, and DEBUGIN among others. The various formatters are also discussed in one of the appendices of the Manual..
For example : My result3 in Line1: is in Binary representation, and I am trying to do a conversion to mill volts using Line 2 statement. My result in Line2 is not correct because I am mixing Binary and decimal value all together. So I would like to convert my Binary result to Decimal before proceeding with Line 2.
Verification: I kept a Debug command after Line1 and Line2 and it gave me different answers. such as
result3= 3918( This is correct)
mVolts3= 0006(This is not correct)
CODE: .......
Line 1: result3 = result3 & value3
Line 2: mVolts3 = ((result3 *5000)/4095 )
You have to try harder than that. Give us something to work with: attach the full source code, with comments on each line where you think it should be decimal or binary and include what you are trying to do.
If result3=3918, then you will have to use different math to convert to millivolts. The formula, 3918 * 5000, overflows the 16 bit limit. Are the values 5000 and 4095 constants? It looks like conversion of a 12 bit ADC reading with a 5 V reference. If so, try one of the following formulae:
mVolts3 = result3 */ 313
or
mVolts3 = result3 ** 14484 + result3 ' more accurate
See */ and ** operators in the PBASIC reference materials.
Comments
There's an operator DIG used to provide a decimal digit of the decimal representation of a number.
There's what's called the DEC formatter used in a variety of I/O statements including SERIN, SEROUT, DEBUG, and DEBUGIN among others. The various formatters are also discussed in one of the appendices of the Manual..
edit: Mike! You did it again!...
Verification: I kept a Debug command after Line1 and Line2 and it gave me different answers. such as
result3= 3918( This is correct)
mVolts3= 0006(This is not correct)
CODE: .......
Line 1: result3 = result3 & value3
Line 2: mVolts3 = ((result3 *5000)/4095 )
You have to try harder than that. Give us something to work with: attach the full source code, with comments on each line where you think it should be decimal or binary and include what you are trying to do.
mVolts3 = result3 */ 313
or
mVolts3 = result3 ** 14484 + result3 ' more accurate
See */ and ** operators in the PBASIC reference materials.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com