MikroC OneWire Example Help

Home Forums Microcontrollers PIC Microcontroller MikroC OneWire Example Help

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #11133
    luismk89
    Participant

    I would like to know why are they adding 48.

    // Convert temp_fraction to characters
    text[4] =  temp_fraction/1000    + 48;         // Extract thousands digit
    text[5] = (temp_fraction/100)%10 + 48;         // Extract hundreds digit
    text[6] = (temp_fraction/10)%10  + 48;         // Extract tens digit
    text[7] =  temp_fraction%10      + 48;         // Extract ones digit
    

    Thanks for your help 🙂

    #11134
    Ligo George
    Keymaster

    It is to convert each extracted digit to corresponding character.
    ‘0’ => 0 + 48
    ‘1’ => 1 + 48
    ‘2’ => 2 + 48
    etc.

    Please refer ASCII Table for more reference.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
>