binary variable

29 Nov 2010

Hello,

 

I would like to use a i2c port extension like the PCF 8575 to test switch position

is there a fonction wich help to translate easely from integer (read on the i2c device  to binary R(0,1,0,0,1,1,0,0) for example ?

with R(0)= false, R(1)=true ?

that's could be a lot more easier than playing with the integer value in conditionnal loop

may be i'm a bit lazy, but if there is something working is already done somewhere ...

may be a C function I haven't be able to find

thank you a lot

 

 

 

29 Nov 2010

i don't know if the function shobit() is available in mbed compiler

 

may be I could use an adaptation of this code

void PrintBin(unsigned int x)
{
    int i; 
    for(i=(sizeof(int)*8); i>=0; i--)
        (x&(1<<i))?putchar('1'):putchar('0');
}

but if there ise a function for that ..... whit a nice conversion in an array ...;-)