c++ - How to loop hex in Javascript? -


in c, output expect. in javascript, output not expect. in javascript, hex loops in decimal not in hexadecimal.

c:

#include<stdio.h> int main(){ for(int i=0x1000;i<=0x109f;i++){     printf("%x\n",i); } return 0; } 

javascript:

<script type="text/javascript"> for(var i=0x1000;i<=0x109f;i++){ document.write(i+"<br>"); } </script> 

you can use tostring method:

document.write(i.tostring(16)+"<br>"); //base 16 (hex) 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -