PDA

View Full Version : HEX2 statement result to variable?



CuriousOne
- 30th January 2014, 14:04
Hello.

I have the code:



lcdout $FE,$C0,"Hr:",HEX2 hh,":",HEX2 mm


which works ok

but when I want to use



A=HEX2 hh


it does not works.

How should I ?

HenrikOlsson
- 30th January 2014, 14:18
Hi,
How should you what?
The HEX, DEC, BIN modifiers are used to present the same number in different ways - but it's still the same number. A value of 10 is always 10 but depending on the modifer used it can be displayed as DECimal (10) HEXadecimal (A) or BINary (00001010) but again it's still the same value.

Lets say hh has the value of 123, what do you expect A to be?

/Henrik.

CuriousOne
- 30th January 2014, 14:47
Yes, so I want to convert a number from BCD to DEC.

I've already found a solution:

hh =( hh >> 4 * 10 ) + ( hh // 16 )

But I thought there should be some statement?