title: Read hex number from file
body: <p>I have (.hex) file that represent data in hexadicimal format. here are sample of the file:</p>
  
  <blockquote>
    <p>:100080000C9408010C9408010C9408010C940801CC
    :100090000C9408010C9408010C9408010C9428019C
    :1000A0000C9408010C9408010C9408010C940801AC
    :1000B0000C9408010C9408010C9408010C9408019C
    :1000C0000C9408010C9408010C9408010C9408018C
    :1000D0000C9408010C9408010C9408010C9408017C</p>
  </blockquote>
  
  <p>I write the following nodejs code to read the file and convert it to Buffer in the end to be sent using serial.</p>
  
  <pre><code>var fs = require("fs");
  
  fs.readFile('./code.hex', function(err, code){
  
      var str = code.toString();
      var line = str.split('\n');
  
      addr = line[1].slice(1, 9);
      //addr_num = Number(addr, 'hex');
  
      data = line[1].slice(9, (line[1].length - 3));
      console.log(data);
      var buf = new Buffer(data, 'hex');
  }
  </code></pre>
  
  <p>The first 8 digits in the line are part of an address and the rest of the line is the data. What I want is to read the <code>addr</code> as a number compare it with other variables using <code>if</code> condition. When I tried <code>addr_num = Number(addr, 'hex');</code> the result was <code>NAN</code>. Is there a way to read it as a number?</p>