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.

floatToStr

Status
Not open for further replies.

Dumken

Member
Pls can someone explain this code 4 Me. Starting from d conversion.
 

Attachments

  • IMG_20131114_144257.jpg
    IMG_20131114_144257.jpg
    1.2 MB · Views: 200
what is "d conversion"?

I don't have much time to write, but there should be a documentation somewhere that explain what each function does.

Or, do you want to know what the "Remove leading blanks" does (or how it does it)?
 
hi T,
Its text speak for 'the' aka 'd'
E
 
hi T,
Its text speak for 'the' aka 'd'
E
Thanks.. english is a second language to me. I am not from d hoods.

mV = (Vin * 5000) >> 10;

That line of code multiplies the adc reading by 5000 and then divides it by 2^10. The result is the adc reading in millivolts. (more or less accurate. Not perfect conversion, but good enough for many)..

EDIT: Sorry.. I think I might have explained the wrong conversion :) .. sorry for that. I'm in a hurry.
 
MisterT yea I mean Removing leading blanks. Thank u.

The for loop goes through the array of letters and copies all letters from the array "op[]" to "lcd[]", except blanks (space-character).

You see the if-statement:

C:
if (op[i] != ' ')
{
    // Copy everything that is not the ' ' character (space-character)
    lcd[j] = op[i];
}
That if-statement compares against the space-character.

If you want to remove all a-characters, then the statement would be:
C:
if (op[i] != 'a')
{
    // Copy everything that is not the 'a' character
    lcd[j] = op[i];
}
Do you see the idea?
 
Last edited:
Thank u mister buh I still don't understand what generated the space n why it was looping from 0 to 11.
 
Thank u mister buh I still don't understand what generated the space n why it was looping from 0 to 11.
The answer lies in the LongToStr() function... The author must have made it a right justify so the string could be terminated in the same spot!..
 
Thank u mister buh I still don't understand what generated the space n why it was looping from 0 to 11.

I don't know what generated the spaces.. well, it is the "LongToStr" function, but I do not know why it generates leading spaces. That is a strange design.

The code probably loops from 0 to 11 because the char array "op[]" is 11 characters long. The code does not show how that variable is defined.

Edit: Ian explained why the function outputs the string "right justified". The code is out of context so it is impossible to explain it with more detail than that.
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top