09-04-2004 05:41 PM
09-08-2004 01:29 PM
06-22-2022 04:08 AM
I know this is a very old thread but I thought that the attached code might still be of help to someone....
06-22-2022 04:28 AM - edited 06-22-2022 04:30 AM
Hi Alan,
@Alan_K. wrote:
the attached code…
There is no code attached, it's just an image!
Why is your code so complicated? Why no use a simple function like this:

06-22-2022 05:00 AM
Thanks for providing a much simpler solution Gerd.
Much appreciated
06-22-2022 05:27 AM
Thank you for your response to my posting Gerd, and your suggested simpler alternative.
However, if you compare the output from the two alternatives, you will see that above a value of 9, your suggestion does not unpack BCD correctly.
Perhaps you could compare the two with inputs from 0 to 99 BCD and post your thoughts.
Thanks again for your contribution 🙂
06-22-2022 06:41 AM - edited 06-22-2022 06:41 AM
Hi Alan,
@Alan_K. wrote:
However, if you compare the output from the two alternatives, you will see that above a value of 9, your suggestion does not unpack BCD correctly.
Perhaps you could compare the two with inputs from 0 to 99 BCD and post your thoughts.
The problem with your image is: you forgot to show the radix for each control/constant/indicator (apart from posting code at all).
My "BCD" input expects a decimal number from 0-99, while yours expects a hexadecimal input from 0-99.
See this changed example:

Now it expects the (usual) hexadecimal input of 0-99. My simplified example still does not check the input value for sanity - as your example also omits…
06-22-2022 06:50 AM - edited 06-22-2022 07:01 AM
@Alan_K. wrote:
I know this is a very old thread but I thought that the attached code might still be of help to someone....
Sorry, but this does not look like BCD. You should have a nibble for each decade, each nibble being a direct decade value. A value of 99 should end with a string of values {0x99}. For a better example, a value of 50 should result in {0x50}. So a Quotient & Remainder is the way to split up the values into decades.
For straight ACII conversion, just using the Number To Decimal String will do the job. It does have an input to set the minimum length of the resulting string if you need 2 or 3 characters.
EDIT: Oh, the input was supposed to be in hex? That changes everything. Yet another reason to attach the actual code instead of just an image. Also the importance of showing the radix whenever it is not the standard decimal.
06-22-2022 07:16 AM
I apologise for not attaching the code, which I have now done.
I am not offering this solution as a general purpose solution, but a simple solution which meets my requirements and for which I could not find a ready made alternative.
The vi input expects only the digits 0 to 9 in High and Low nibbles i.e 0 to 99 (BCD) No checking is implemented
Have I missed a ready made function / solution elsewhere? 🤔
06-22-2022 08:11 AM
@Alan_K. wrote:
I apologise for not attaching the code, which I have now done.
I am not offering this solution as a general purpose solution, but a simple solution which meets my requirements and for which I could not find a ready made alternative.
The vi input expects only the digits 0 to 9 in High and Low nibbles i.e 0 to 99 (BCD) No checking is implemented
Have I missed a ready made function / solution elsewhere? 🤔
I notice you are STILL not showing the radix on your numeric control. HOW IS THE USER SUPPOSED TO KNOW THE INPUT IS SUPPOSED TO BE HEXADECIMAL? (There's been any number of subtle hints so far; I thought I'd make mine not-so-subtle.)