Search code examples
binaryfloating-pointhexcalculatoroctal

floating point hex octal binary


I am working on a calculator that allows you to perform calculations past the decimal point in octal, hexadecimal, binary, and of course decimal. I am having trouble though finding a way to convert floating point decimal numbers to floating point hexadecimal, octal, binary and vice versa.

The plan is to do all the math in decimal and then convert the result into the appropriate number system. Any help, ideas or examples would be appreciated.

Thanks!


Solution

  • Hmm... this was a homework assignment in my university's CS "weed-out" course.

    The operations for binary are described in Schaum's Outline Series: Essential Computer Mathematics by Seymour Lipschutz. For some reason it is still on my bookshelf 23 years later.

    As a hint, convert octal and hex to binary, perform the operations, convert back to binary.

    Or you can perform decimal operations and perform the conversions to octal/hex/binary afterward. The process is essentially the same for all positional number systems arithmetic.