Dig Command Question

Dave E

Senior Member
I am trying to print a number to a LCD. The number is in a byte of memory but I need to print a decimal point between digit 0 and digit 1. For example, if the number in memory is 155 it represents a voltage of 15.5 volts. My code includes the line:
B3 = B1 DIG 0
I get a syntax error on this line.
What is wrong with it?
I have also used B3 = B1 DIG 0 + "0" with the same results.

The manual states that The DIG command returns the decimal value of a 16 bit number. Therefore digit 0 of '67890' is 0 and digit 3 is '7'. To return an ascii value of the digit simply add ascii "0" to the digit value e.g.
let b1 = b2 DIG 0 + "0".
Since I want the decimal value of a number I assume that B1 = B2 DIG 0 is the correct syntax to use.

What I would like to use is somthing like this:
Serout 4, T2400, (#B1 DIG 2, #B1 DIG 1, ".", #B1 DIG 0)

Any ideas what I am doing wrong?

Dave
 

Dave E

Senior Member
Oops.
I'm using an 08M.
Thanks eclectic, I missed that. I'll have to come up with another way to break out the individual digits.

Dave
 

Brietech

Senior Member
if say you wanted to print b0, but you want the last digit to be behind a decimal point:

b1 = b0 / 10 'upper part of number
b2 = b0 // 10 'gets the remainder

sertxd(#b1,".",#b2)
 

eclectic

Moderator
Actually, there IS a way.

/10
//10

BUT, that'll be part of the fun of learning.

Look at Manual 2, page 19.
Initially Brain-boiling, but ............
e
 

Dave E

Senior Member
That's the way I've done it in the past. It does the job just fine but uses a bit more code/memory.

Dave
 
Top