Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Binary, Octal, Hex and Decimal conversions??

  • 17-04-2009 7:50am
    #1
    Registered Users, Registered Users 2 Posts: 329 ✭✭


    Hey im studying c++ and was wondering how to convert from binary to hexadecimal to octal and vice versa. Just studying for test in a month and need serious help on the subject... Thanks..


Comments

  • Closed Accounts Posts: 5,096 ✭✭✭--amadeus--


    Have you had a chance to read teh charter?

    Try this as well.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    Nappy wrote: »
    Hey im studying c++ and was wondering how to convert from binary to hexadecimal to octal and vice versa. Just studying for test in a month and need serious help on the subject... Thanks..

    From your question it is not clear what you want to do. Before you can do anything in programming you need to have it clear and express it in plain english.

    Do you want to convert an integer variable into a string representation of different bases (binary, hex & octal)? And convert a string representations of a number (with binary/hex/octal) back to an integer?

    There's various ways you can do this, are you supposed to code the conversion from scratch or use libraries?

    The binary conversion is very easy to do from scratch, with a for loop and some bit shifts.

    The hex conversion is easy enough too you can use the %x in a printf, or use std::hex in a cout statement. I think think you can also use std::hex in a cin or a buffered string also, to do the opposite conversion.


  • Registered Users, Registered Users 2 Posts: 15,065 ✭✭✭✭Malice


    Nappy wrote: »
    Hey im studying c++ and was wondering how to convert from binary to hexadecimal to octal and vice versa. Just studying for test in a month and need serious help on the subject... Thanks..
    Did you try Google? Also I think you should have taken note of what the mod posted on your last thread.


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    There are probably APIs for doing it but the easy way if you had to write your own is to create a lookup table. Base 2 to Base 26. :D


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    :mad:


  • Advertisement
This discussion has been closed.
Advertisement