Link to home
Start Free TrialLog in
Avatar of OdinXp2000
OdinXp2000

asked on

how can I change 10 bit data into 2 bit data

it means change a dec number into a bin number
Avatar of pjknibbs
pjknibbs

We're not allowed to answer homework questions, unfortunately, so I doubt you're going to get a reply to this one.
Avatar of ozo
What do you mean by change 10 bit data into 2 bit data?
throw 8 bits away. But why?
keep the most significant 2 bits. This can be done for images, for example. Convert 256 to 16 color depth, just keep the top bits and its a rough way to do that...
ASKER CERTIFIED SOLUTION
Avatar of Anders_Rasmussen
Anders_Rasmussen

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
example:

#include <stdio.h>

void main () {
    char InputString[] = "1047";
    char OutputString[5];
    int Value;
    int Ret;

    /* Convert decimal string to internal format*/
    /* internaly its binary*/
    Ret = sscanf ( InputString, "%d", &Value);
    if ( Ret != 1 ) { exit -1; }

    /* Convery internal representation binary to binary string */
   
}

Avatar of OdinXp2000

ASKER

Thank all of you very much!