Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Programming doubt

Status
Not open for further replies.
And you mean look-up tables for getting the ascii value of a number digit?

Then in C, why not use the same? I mean create a look-up table too.

However, you can also use something else. If you look at the ascii table, digits 0 to 9 have consecutive ascii values, starting from 0x30 or 48 decimal. So you can add the digit you have to the 48 value and the result of the summation is the ascii code of your digit!

However, please be more detailed in your question. Perhaps I have understood something different.
 
i'm guessing you are looking for something to convert numbers to an ASCII string for displaying:

char numberString[20];

// convert int to string
snprintf(numberString, sizeof(numberString), "%d", numberToDisplay);

// terminate string, just in case
numberString[sizeof(numberString) - 1] = 0;

// display the string
yourDisplayFunction(numberString);

--- alternatively you can use sprintf instead of snprintf if that function is not supported by your compiler's library
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top