Convert decimal numbers to binary

2010-04-21 138 words 1 min read

\"SYDNEY,
Image by Getty Images via Daylife

There is a calculator called bc that works in the command line. So if you need a quick calculator function in the command line then you could write some functions that will do the trcik for you. Here is an example:

function convBase { echo "ibase=$1; obase=$2; $3" | bc; }

so, if you want to convert decimal number to hex number then you could type

convBase 10 16 16
<h6 class="zemanta-related-title">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://www.beingpeterkim.com/2009/11/binary-thinking.html">Binary thinking (beingpeterkim.com) <li class="zemanta-article-ul-li"><a href="http://gizmodo.com/5349516/the-real-reason-you-got-back-so-much-hard-drive-space-with-snow-leopard">The Real Reason You Got Back So Much Hard Drive Space With Snow Leopard [Apple] (gizmodo.com) <li class="zemanta-article-ul-li"><a href="http://www.killerstartups.com/Web-App-Tools/errornow-com-common-errors-when-typing-urls">ErrorNow.com – Common Errors When Typing URLs (killerstartups.com) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/35c1a728-6257-4ae0-b178-9071e9056b1b/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b21.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">


author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it