# Base Number Conversion Routines

### WEBINAR:On-Demand

Application Security Testing: An Integral Part of DevOps

Here are two routines that will take any decimal number and convert it to any number base between 2 and 36 and vice-versa. The first routine, ConvertDecToBaseN, takes the decimal number and the base to convert it to as parameters. If no base is supplied, then base 16 (hexadecmial) is assumed. The original author of this routine is Peter Rodriguez. I got his code from www.devx.com - it was a "Tip of the Day". In his tip, he encouraged the reader to derive a partner function that would bring his converted number back to base 10. So I accepted his challenge and wrote the second routine, ConvertBaseNToDec, which is modeled after his routine and takes the converted number and converted number's base as parameters and returns the decimal equivalent. If no base is supplied, then base 16 is assumed.

Note: these functions only work with whole numbers. They do not convert rational or irrational numbers correctly at this point.

The code comes with a sample project showing how the routines should be used.

• #### http://www.codeguru.com/vb/articles/2137.shtml

Posted by Legacy on 12/27/2001 12:00am

Originally posted by: CHris Majagah

Very very nice neat code for converting numbers to different base numbers

• You must have javascript enabled in order to post comments.

## Top White Papers and Webcasts

• As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
• The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
• Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

## Most Popular Programming Stories

• There have been no articles posted today.