i need m-file to convert decimal to hexadecimal without using the built in command deci2hex

Answers (2)

I won't give you an m-file, but here's an outline of how to proceed, Malek. If you are dealing with positive integers, do a mod(~,16) on your integer to get its least hex digit. It will range from 0 to 15. Next subtract this digit from your number and divide the difference by 16. Then repeat the above steps for the next higher hex digit. Continue this process, each time producing another higher hex digit, until the integer has been reduced to zero. The sequence of digits you have obtained this way constitute your number expressed in hexadecimal. This outline should help you to write your own conversion routine.

Categories

Asked:

on 20 Dec 2013

Commented:

on 21 Dec 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!