René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

parseInt [JavaScript snippet]

function main() {

  var hex = "0xff"    // 255
  var oct = "077"     //  63 (sic!)
  var dec = "222"     // 222
  var frc = "17.77"   //  17 (rounds down)
  var spc = "28 88"   //  28 (rounds down)
  var lea = "  99 "   //  99
  var chr = " 42!!"   //  42
  var nan = "!164"    //  NaN

  txt_out('hex: ' + parseInt(hex)) 
  txt_out('oct: ' + parseInt(oct)) 
  txt_out('dec: ' + parseInt(dec)) 
  txt_out('frc: ' + parseInt(frc)) 
  txt_out('spc: ' + parseInt(spc)) 
  txt_out('lea: ' + parseInt(lea)) 
  txt_out('chr: ' + parseInt(chr)) 
  txt_out('nan: ' + parseInt(nan)) 

  // ----

  // specifying a radix:

  txt_out('oct, radix 10: ' + parseInt(oct, 10)); // 77
}