Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Input binary variables in C

Name: Anonymous 2009-06-16 9:42

how can i input binary variables in C?
like: int c=b01010101

Name: Anonymous 2009-06-16 9:45

all variables are stored in binary.

Name: Anonymous 2009-06-16 9:45

Convert them to decimal or hexadecimal.

Name: Anonymous 2009-06-16 9:46

You can't do that. Read the C FAQ.

Name: Anonymous 2009-06-16 9:48

The C compiler from Micrchip for PICs allows you to enter binary numbers. Computer programmers are more advanced. They use base16.

Name: Anonymous 2009-06-16 9:52

write a perl script

Name: Anonymous 2009-06-16 10:31


unsigned int lol(char *s) {
  int r=0,m=strlen(s)-1;
  for(;*s;m--)
    if(*s++-48)
      r+=1<<m;
  return r;
}

Name: Anonymous 2009-06-16 12:36

>>7
Can't this be done in the preprocessor to eliminate runtime overhead?

Better question: does any compiler precalculate static functions called with compile-time known values? I know some of them do it for some specific functions (mostly math stuff), but I wonder if it's more spread.

Name: Anonymous 2009-06-16 13:14

GNU C implements an (ex.) 0b11101101 extension if you're not looking to abide by any sort of standards.

Name: Anonymous 2009-06-16 13:24

>>9
But GNU is the standard!

Name: Anonymous 2009-06-16 18:23

>>8
run time overhead...???  you can just run it once at the start and cache it ...

Name: Anonymous 2009-06-16 18:52

>>8
Don't write proper/on topic replies AND saging

Name: Anonymous 2009-06-16 21:44

>>10
Despite the fact that your post was humerus and amusing, it actually had some valid content so it's EXTREMBLY RUDE OF YOU TO SAGE HOW DARE YOU

Name: Anonymous 2009-06-17 1:48

>>13
humerus
0/10

Name: Trollbot9000 2009-07-01 9:16

Values used as keys?

Don't change these.
Name: Email:
Entire Thread Thread List