can anyone help me pls :(

buddhika19

Active member
  • Apr 26, 2007
    6,940
    7
    38
    40
    Piliyandala - Sri Lanka
    1. What is the binary equivalent of the signed integer -19?

    2. What is the unsigned integer which corresponds to the hexadecimal E8?

    3. What is the IEEE 754 representation of the signed decimal number -12.25?

    can anyone help aobut these 3 questions pls

    :(:(:(:(:(
     

    methsri

    Well-known member
  • Dec 17, 2007
    3,882
    240
    63
    40
    In ThE R3AL W0RLD
    Not sure abt da 2nd Quection , easiest way is to run da following programme and see da output


    #include "stdafx.h"

    #include <tchar.h>

    #include <malloc.h>


    int _httoi(const TCHAR *value)
    {
    struct CHexMap
    {
    TCHAR chr;
    int value;
    };
    const int HexMapL = 16;
    CHexMap HexMap[HexMapL] =
    {
    {'0', 0}, {'1', 1},
    {'2', 2}, {'3', 3},
    {'4', 4}, {'5', 5},
    {'6', 6}, {'7', 7},
    {'8', 8}, {'9', 9},
    {'A', 10}, {'B', 11},
    {'C', 12}, {'D', 13},
    {'E', 14}, {'F', 15}
    };
    TCHAR *mstr = _tcsupr(_tcsdup(value));
    TCHAR *s = mstr;
    int result = 0;
    if (*s == '0' && *(s + 1) == 'X') s += 2;
    bool firsttime = true;
    while (*s != '\0')
    {
    bool found = false;
    for (int i = 0; i < HexMapL; i++)
    {
    if (*s == HexMap.chr)
    {
    if (!firsttime) result <<= 4;
    result |= HexMap.value;
    found = true;
    break;
    }
    }
    if (!found) break;
    s++;
    firsttime = false;
    }
    free(mstr);
    return result;
    }

    int main(int argc, char* argv[])
    {
    TCHAR *test[4] = {_T("0xFFFF"), _T("0xabcd"), _T("ffff"), _T("ABCD")};
    for (int i = 0; i < 4; i++)
    _tprintf(_T("Hex String: %s is int: %d\n\r"), test, _httoi(test));
    return 0;
    }
     
    Not sure abt da 2nd Quection , easiest way is to run da following programme and see da output


    #include "stdafx.h"

    #include <tchar.h>

    #include <malloc.h>


    int _httoi(const TCHAR *value)
    {
    struct CHexMap
    {
    TCHAR chr;
    int value;
    };
    const int HexMapL = 16;
    CHexMap HexMap[HexMapL] =
    {
    {'0', 0}, {'1', 1},
    {'2', 2}, {'3', 3},
    {'4', 4}, {'5', 5},
    {'6', 6}, {'7', 7},
    {'8', 8}, {'9', 9},
    {'A', 10}, {'B', 11},
    {'C', 12}, {'D', 13},
    {'E', 14}, {'F', 15}
    };
    TCHAR *mstr = _tcsupr(_tcsdup(value));
    TCHAR *s = mstr;
    int result = 0;
    if (*s == '0' && *(s + 1) == 'X') s += 2;
    bool firsttime = true;
    while (*s != '\0')
    {
    bool found = false;
    for (int i = 0; i < HexMapL; i++)
    {
    if (*s == HexMap.chr)
    {
    if (!firsttime) result <<= 4;
    result |= HexMap.value;
    found = true;
    break;
    }
    }
    if (!found) break;
    s++;
    firsttime = false;
    }
    free(mstr);
    return result;
    }

    int main(int argc, char* argv[])
    {
    TCHAR *test[4] = {_T("0xFFFF"), _T("0xabcd"), _T("ffff"), _T("ABCD")};
    for (int i = 0; i < 4; i++)
    _tprintf(_T("Hex String: %s is int: %d\n\r"), test, _httoi(test));
    return 0;
    }

    wow