0

We can input decimal, octal and hexadecimal numbers using scanf. We can output decimal, octal, hexadecimal using printf.. Why not binary numbers? why they are excluded?

KawaiKx
  • 9,558
  • 19
  • 72
  • 111
  • 2
    Same reason that base 6 and base 51 are excluded? – Kerrek SB Mar 30 '14 at 15:35
  • 1
    It's never about "not allowed"; you can code it yourself. It's about "Will this be significantly helpful to enough people to justify its inclusion in the library"... and the answer for this example is "no". – keshlam Mar 30 '14 at 15:42
  • 1
    Duplicate?! [Why doesn't C have binary literals?](http://stackoverflow.com/questions/18244726/why-doesnt-c-have-binary-literals) – masoud Mar 30 '14 at 15:48
  • Look up `strtol` , it is in the standard library. One of the arguments is the base of the number system. – Gábor Buella Mar 30 '14 at 16:27

1 Answers1

4

Because any competent programmer can easily do binary number output and input himself, it's too verbose, and hexadecimal is just as good for flags and an easy transformation?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
  • 1
    Which is the reason that is _only_ a supporting argument. The meat is in verbosity, feature creep, and already including a format humans can easily transform. BTW: Many are of the opinion that including octal was a grave mistake. It is rarely used by intent. – Deduplicator Mar 30 '14 at 15:43
  • 1
    confident that octal was in greater usage than hexadecimal _back in the day_ of nascent C. Hexadecimal was the new kid on the block and part of a successful feature creep. I agree octal has limited uses today. – chux - Reinstate Monica Mar 30 '14 at 16:50