Working with digits.. how do i.....
Archiver
Posts: 46,084
I can't seem to find a way to combine 3 nibbles with single digit values
into one bye that hold the values of the nibbles in digits 1 2 & 3.
hopefully I can explain it better with below.
I have:
digita var nib
digitb var nib
digitc var nib
target var byte
digita = 1
digitb = 2
digitc = 5
I want target to equal 125. Can it be done with a BS2P40?
-Rob
into one bye that hold the values of the nibbles in digits 1 2 & 3.
hopefully I can explain it better with below.
I have:
digita var nib
digitb var nib
digitc var nib
target var byte
digita = 1
digitb = 2
digitc = 5
I want target to equal 125. Can it be done with a BS2P40?
-Rob
Comments
digita = digita
digitb = digitb * 10
digitc = digitc * 100
target = digita + digitb + digitc
I hope this works. keep your eyes open, the masters for math might be able to
find a better way.
AJ
--- In basicstamps@y..., "Robert Staph" <rstaph@a...> wrote:
> I can't seem to find a way to combine 3 nibbles with single digit values
> into one bye that hold the values of the nibbles in digits 1 2 & 3.
> hopefully I can explain it better with below.
>
> I have:
> digita var nib
> digitb var nib
> digitc var nib
> target var byte
>
> digita = 1
> digitb = 2
> digitc = 5
>
> I want target to equal 125. Can it be done with a BS2P40?
>
> -Rob
[noparse][[/noparse]Non-text portions of this message have been removed]
target=(digita*100)+(digitb*10)+digitc
Right?
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: Robert Staph [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=XbBbrCzZozwUotARVY84rjj4VpWSy_Z4Yb82dwg5ZvB3mUpHkV_d686bLYasyI0Y3LVYP_MVDGMgbEJc]rstaph@a...[/url
> Sent: Sunday, January 27, 2002 8:54 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Working with digits.. how do i.....
>
>
> I can't seem to find a way to combine 3 nibbles with single
> digit values into one bye that hold the values of the nibbles
> in digits 1 2 & 3. hopefully I can explain it better with below.
>
> I have:
> digita var nib
> digitb var nib
> digitc var nib
> target var byte
>
> digita = 1
> digitb = 2
> digitc = 5
>
> I want target to equal 125. Can it be done with a BS2P40?
>
> -Rob
>
>
> 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/
>
a for/next loop, but this will save code space.
-Rob
Original Message
From: "Al Williams" <alw@a...>
To: <basicstamps@yahoogroups.com>
Sent: Sunday, January 27, 2002 10:34 PM
Subject: RE: [noparse][[/noparse]basicstamps] Working with digits.. how do i.....
>
> If I understand:
>
> target=(digita*100)+(digitb*10)+digitc
>
> Right?
>
> 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: Robert Staph [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=urJcroRT3cWKVyuKQCwAK3HitjQkn3MtgZdSvNPwxKNgKMlptW6mBgl0p2igqioQpJtSGqHWKrN-1Fs]rstaph@a...[/url
> > Sent: Sunday, January 27, 2002 8:54 PM
> > To: basicstamps@yahoogroups.com
> > Subject: [noparse][[/noparse]basicstamps] Working with digits.. how do i.....
> >
> >
> > I can't seem to find a way to combine 3 nibbles with single
> > digit values into one bye that hold the values of the nibbles
> > in digits 1 2 & 3. hopefully I can explain it better with below.
> >
> > I have:
> > digita var nib
> > digitb var nib
> > digitc var nib
> > target var byte
> >
> > digita = 1
> > digitb = 2
> > digitc = 5
> >
> > I want target to equal 125. Can it be done with a BS2P40?
> >
> > -Rob
> >
> >
> > 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/
>
>
>
may be of use.
When nibbles are used to represent decimal digits, it's referred to
as BCD, or Binary Coded Decimal.
Typically, each nibble holds a value from 0 (%0000) to 15 (%1111),
which is the basis for the hexidecimal numbering system where each
nibble can hold a value of 0 to F.
If the nibble value is limited to 9 max (binary 1001) each nibble
then represents the decimal value.
In your example if you only wanted to display the value, we could use
the HEX modifier to display the BCD value:
digita var nib
digitb var nib
digitc var nib
target var byte
digita = 1
digitb = 2
digitc = 5
DEBUG HEX digita,HEX digitb,HEX digitc,CR
Another thing that could be done is define a word varaible, then
parse out its individual nibbles to other variable names alleviating
the need to re-assemble the nibbles and saving memory.
DIGIT Var WORD
Digit1 var DIGIT.NIB3
Digit2 var DIGIT.NIB2
Digit3 var DIGIT.NIB1
Digit4 var DIGIT.NIB0
Digit1 = 1
Digit2 = 2
Digit3 = 3
Digit4 = 4
DEBUG HEX DIGIT,CR
-Martin Hebel
Care to have a GUI for your Stamp?
http://www.selmaware.com/stampplot
Want to learn more abot electronics?
http://www.siu.edu/~imsasa/est
--- In basicstamps@y..., "Robert Staph" <rstaph@a...> wrote:
> I can't seem to find a way to combine 3 nibbles with single digit
values
> into one bye that hold the values of the nibbles in digits 1 2 & 3.
> hopefully I can explain it better with below.
>
> I have:
> digita var nib
> digitb var nib
> digitc var nib
> target var byte
>
> digita = 1
> digitb = 2
> digitc = 5
>
> I want target to equal 125. Can it be done with a BS2P40?
>
> -Rob
Thanks,
Ray McArthur
Original Message
From: selmaware <martin@s...>
To: <basicstamps@yahoogroups.com>
Sent: Sunday, January 27, 2002 11:31 PM
Subject: [noparse][[/noparse]basicstamps] Re: Working with digits.. how do i.....
> This may not help you, but it does bring up a good discussion that
> may be of use.
>
> When nibbles are used to represent decimal digits, it's referred to
> as BCD, or Binary Coded Decimal.