title: How to convert a double to a hex / bytes
body: <p>I need to send data to The Things Network and the data need to in bytes</p>
  
  <blockquote>
    <p>To send data back and forth over The Things Network you’ll need to use
    bytes</p>
  </blockquote>
  
  <p>Some functions return a float with 2 decimal</p>
  
  <blockquote>
    <p>23.56
    or 
    4.32</p>
  </blockquote>
  
  <p>I have big difficulties to convert my float and save it to a varaible uint8_t my data. I have to find how to convert my float variable</p>
  
  <p>I have a loop like this:</p>
  
  <pre><code>/*
  NOTE:
  uinit8_t mydata[64];
  byte nbMaxCapteurs = 10;
  mesMesures[i][mesCapteur[i].idDuCapteur].valeur =&gt; this is a float
  */
  
  memset(mydata, 0xFF, 64);
  uint8_t * ptr = mydata;
  for (byte i = 0; i &lt; nbMaxCapteurs; i++) {
    if (mesCapteur[i].actif) {
      *ptr = mesMesures[i][mesCapteur[i].idDuCapteur].valeur;
      ptr += 15; // How to know the number of step to move the pointer
      if (i &lt; nbCapteurActif + 1) {
        *ptr = 0x2C; // virgule
        ptr += sizeof(char);
      }
    } else {
      *ptr = 0x2C; // virgule pour les capteurs inactifs
      ptr += sizeof(char);
    }
  }
  *ptr = '00'; // Close \0
  ptr += sizeof(char);
  printData();
  </code></pre>
  
  <p>I am very new to such conversions. The real problem is here:</p>
  
  <pre><code>*ptr = mesMesures[i][mesCapteur[i].idDuCapteur].valeur;
  </code></pre>
  
  <p>printData prints this:</p>
  
  <blockquote>
    <p>04 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2C 18 FF FF FF FF FF FF
    FF FF FF FF FF FF FF FF 2C CB FF FF FF FF FF FF FF FF FF FF FF FF FF
    FF 2C A8 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2C</p>
  </blockquote>
  
  <p>But it should print at least this:</p>
  
  <blockquote>
    <p>34 2E 33 32 FF FF FF FF FF FF FF FF FF FF FF 2C 18 FF FF FF FF FF FF
    FF FF FF FF FF FF FF FF 2C CB FF FF FF FF FF FF FF FF FF FF FF FF FF
    FF 2C A8 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 2C</p>
  </blockquote>
  
  <p>Because <code>34 2e 33 32</code> is equals to 4.32.</p>
  
  <p>I don't understand and don't know how I can "merge" and convert a float value. And then could you help me move the pointer following the size of the float?</p>
  
  <p>I'm really stuck with that topic and I would really appreciate your help.</p>