how to convert a decimal no. into a bin, oct & hexa no. using builtin function in C++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mshahzadali
    New Member
    • Mar 2007
    • 1

    how to convert a decimal no. into a bin, oct & hexa no. using builtin function in C++

    is there any expert who could guide me making a C++ program. I want to convert a Decimal number into a Binary, Octal and a Hexadecimal Number using a C++ Built-in Function(if there exist any).
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    Originally posted by mshahzadali
    is there any expert who could guide me making a C++ program. I want to convert a Decimal number into a Binary, Octal and a Hexadecimal Number using a C++ Built-in Function(if there exist any).
    you can read and write in various number formats using IO manipulators, see
    http://www.cppreferenc e.com/io_flags.html

    otherwise have a look at this on conversion between number systems
    http://en.wikipedia.or g/wiki/Binary_numeral_ system#Conversi on_to_and_from_ other_numeral_s ystems

    Comment

    • Savage
      Recognized Expert Top Contributor
      • Feb 2007
      • 1759

      #3
      Originally posted by mshahzadali
      is there any expert who could guide me making a C++ program. I want to convert a Decimal number into a Binary, Octal and a Hexadecimal Number using a C++ Built-in Function(if there exist any).
      Maybe you can convert them with format specifiers

      "%o"-unsigned octal

      "%x"-unsigned hexadecimal with lowercase characters

      "%X-unsigned hexadecimal with upercase characters

      Comment

      Working...