Translate

Decimal to Hex Converter

("Please enter the number to convert from Decimal to Hexidecimal"
answer

2 comments :

  1. function convert(n) {
    var hex="";
    while(n>16){
    hex=decision(n%16) + ""+hex;
    n=~~(n/16);
    }
    if(n>0){
    hex=decision(n%16) + ""+hex;
    }

    return hex;
    }

    function decision(d){
    if (d >= 0 && d <= 9){
    return d;
    }
    if(d==10){
    return "A";
    }
    if(d==11){
    return "B";
    }
    if(d==12){
    return "C";
    }
    if(d==13){
    return "D";
    }
    if(d==14){
    return "E";
    }
    if(d==15){
    return "F";
    }

    }

    ReplyDelete