Easy question about formatting a string
-
Hi everyone, Just a quick question. Is there a way to display binary when formatting a string? I know %d is decimal, %X is hex....is there one that even exists for binary? Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
-
Hi everyone, Just a quick question. Is there a way to display binary when formatting a string? I know %d is decimal, %X is hex....is there one that even exists for binary? Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
-
Hi everyone, Just a quick question. Is there a way to display binary when formatting a string? I know %d is decimal, %X is hex....is there one that even exists for binary? Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
NewHSKid wrote: ...is there one that even exists for binary? No, you'll need to roll your own.
Five birds are sitting on a fence. Three of them decide to fly off. How many are left?
-
Hi everyone, Just a quick question. Is there a way to display binary when formatting a string? I know %d is decimal, %X is hex....is there one that even exists for binary? Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
There are several ways. Here are a few. The example below will display the binary representation for the decimal 100. In addition to '#including' <bitset>, you'll also have to '#include' <limits> cout<<"\n 100: " <::bitset(85) <('A') < Ltrs = bitset<numeric_limits<unsigned int>::digits>('ABCD'); cout<<"\n \"ABCD\": " <