hexa convertion - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

hexa convertion

jagadeesanjagadeesan Posts: 2Member
can any one please help me to write hexa convertion program without using (%x) control string function.

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    : can any one please help me to write hexa convertion program without using (%x) control string function.
    :

    hex digits are in the range '0' to '9' and 'A' to 'F', where 'A' = 10, 'B' = 11, etc. So if you have a hex string, just convert each digit to its decimal binary value. A digit can be converted to its binary value like this:
    [code]
    int n;
    char digit = '0';
    // just subtrace '0' from any digit that is in
    // the range '0' to '9'.
    n = digit - '0';
    //
    // convert 'A' to decimal binary value
    char digit = 'A';
    n = (digit - 'A') + 10;
    [/code]

    Post some code if you have other problems.
Sign In or Register to comment.