<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Linux / UNIX: Convert Hexadecimal to Decimal Number</title> <atom:link href="http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/feed/" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/</link> <description>Every answer asks a more beautiful question.</description> <lastBuildDate>Fri, 10 Feb 2012 19:55:56 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: sovan</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-64887</link> <dc:creator>sovan</dc:creator> <pubDate>Fri, 25 Nov 2011 18:09:01 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-64887</guid> <description>how the conversion will possible when a user will give a number on his choice or from command line argument.</description> <content:encoded><![CDATA[<p>how the conversion will possible when a user will give a number on his choice or from command line argument.</p> ]]></content:encoded> </item> <item><title>By: adithya kiran</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-55928</link> <dc:creator>adithya kiran</dc:creator> <pubDate>Wed, 23 Feb 2011 06:54:16 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-55928</guid> <description>Hi,
You can use the following command to convert from any to any base.. for example binary to dec and dec to binary
# perl -e &#039;printf &quot;%b\n&quot; 10&#039;
1010
# perl -e &#039;printf &quot;%d\n&quot; 0b1010&#039;
10</description> <content:encoded><![CDATA[<p>Hi,</p><p>You can use the following command to convert from any to any base.. for example binary to dec and dec to binary</p><p># perl -e &#8216;printf &#8220;%b\n&#8221; 10&#8242;<br
/> 1010<br
/> # perl -e &#8216;printf &#8220;%d\n&#8221; 0b1010&#8242;<br
/> 10</p> ]]></content:encoded> </item> <item><title>By: Justin Anonymous</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-43800</link> <dc:creator>Justin Anonymous</dc:creator> <pubDate>Wed, 23 Sep 2009 18:00:48 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-43800</guid> <description>As others have mentioned, there is so much wrong with this article.  Someone needs to update it.
drpyro:  what is not mentioned is once you set ibase, all numbers after are treated in that base.  For your code, it should look like this:
&lt;code&gt;echo &quot;ibase=2; obase=1010; 111101101&quot; &#124; bc&lt;/code&gt;
Get it?  The obase number has to be in binary (1010b = 10 decimal).</description> <content:encoded><![CDATA[<p>As others have mentioned, there is so much wrong with this article.  Someone needs to update it.</p><p>drpyro:  what is not mentioned is once you set ibase, all numbers after are treated in that base.  For your code, it should look like this:<br
/> <code>echo "ibase=2; obase=1010; 111101101" | bc</code></p><p>Get it?  The obase number has to be in binary (1010b = 10 decimal).</p> ]]></content:encoded> </item> <item><title>By: drpyro</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-42374</link> <dc:creator>drpyro</dc:creator> <pubDate>Sat, 04 Jul 2009 01:49:22 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-42374</guid> <description>this command fail to give me the result on base 10, im i writing it the wrong way ?
&lt;code&gt; echo &quot;ibase=2;obase=10;111101101&quot; &#124; bc &lt;/code&gt;
when i omit obase i have the right answer exp: &lt;code&gt;echo &quot;ibase=2;111101101&quot; &#124; bc &lt;/code&gt; which is :&lt;code&gt;493&lt;/code&gt;
I&#039;m using bc  1.06.94</description> <content:encoded><![CDATA[<p>this command fail to give me the result on base 10, im i writing it the wrong way ?<br
/> <code> echo "ibase=2;obase=10;111101101" | bc </code></p><p>when i omit obase i have the right answer exp: <code>echo "ibase=2;111101101" | bc </code> which is :<code>493</code><br
/> I&#8217;m using bc  1.06.94</p> ]]></content:encoded> </item> <item><title>By: PK</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40776</link> <dc:creator>PK</dc:creator> <pubDate>Mon, 16 Mar 2009 06:48:54 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40776</guid> <description>One more way I know.
from dec. to hex. conversion:
$echo &#039;ibase=10; obase=16; 1237184449&#039; &#124; bc
49BDEFC1
from hex. to dec. conversion: (here you specify obase in hex notation ( A=10 )
$echo &#039;ibase=16; obase=A; 49BDEFC1&#039; &#124; bc
1237184449</description> <content:encoded><![CDATA[<p>One more way I know.</p><p>from dec. to hex. conversion:<br
/> $echo &#8216;ibase=10; obase=16; 1237184449&#8242; | bc<br
/> 49BDEFC1</p><p>from hex. to dec. conversion: (here you specify obase in hex notation ( A=10 )<br
/> $echo &#8216;ibase=16; obase=A; 49BDEFC1&#8242; | bc<br
/> 1237184449</p> ]]></content:encoded> </item> <item><title>By: PK</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40775</link> <dc:creator>PK</dc:creator> <pubDate>Mon, 16 Mar 2009 06:42:43 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40775</guid> <description>I agrre with Mockey Chen.
convert dec to hex:
$ printf “%x” 100
convert hex to dec:
$ printf “%d” 0xf4
Or simply do in bash (for hex to dec. conversion):
echo $((0x100))</description> <content:encoded><![CDATA[<p>I agrre with Mockey Chen.</p><p>convert dec to hex:<br
/> $ printf “%x” 100</p><p>convert hex to dec:<br
/> $ printf “%d” 0xf4</p><p>Or simply do in bash (for hex to dec. conversion):<br
/> echo $((0&#215;100))</p> ]]></content:encoded> </item> <item><title>By: mhymn</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40475</link> <dc:creator>mhymn</dc:creator> <pubDate>Wed, 25 Feb 2009 11:31:36 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40475</guid> <description>aptitude install gbase &amp;&amp; man gbase
:)</description> <content:encoded><![CDATA[<p>aptitude install gbase &amp;&amp; man gbase<br
/> :)</p> ]]></content:encoded> </item> <item><title>By: asdf</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40308</link> <dc:creator>asdf</dc:creator> <pubDate>Sun, 15 Feb 2009 16:21:07 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40308</guid> <description>0xac != 99, which one should see on a first glance or at least manually check before posting.
bc defaulting to decimal for input AND output saved you in your first example.
Finally clobbering and depending on the .bashrc when there is printf on every unix is unnecessary.</description> <content:encoded><![CDATA[<p>0xac != 99, which one should see on a first glance or at least manually check before posting.<br
/> bc defaulting to decimal for input AND output saved you in your first example.<br
/> Finally clobbering and depending on the .bashrc when there is printf on every unix is unnecessary.</p> ]]></content:encoded> </item> <item><title>By: Mockey Chen</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40186</link> <dc:creator>Mockey Chen</dc:creator> <pubDate>Mon, 09 Feb 2009 02:10:20 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40186</guid> <description>How about just using printf, for example:
convert dec to hex:
$ printf &quot;%x&quot; 100
convert hex to dec:
$ printf &quot;%d&quot; 0xf4
simple and easy way.</description> <content:encoded><![CDATA[<p>How about just using printf, for example:<br
/> convert dec to hex:<br
/> $ printf &#8220;%x&#8221; 100</p><p>convert hex to dec:<br
/> $ printf &#8220;%d&#8221; 0xf4</p><p>simple and easy way.</p> ]]></content:encoded> </item> <item><title>By: Maqbool Patel</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40177</link> <dc:creator>Maqbool Patel</dc:creator> <pubDate>Sun, 08 Feb 2009 05:17:54 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40177</guid> <description>Thanks, these days I am working on some byte level code reading file offsets and I was using a calculator to do this conversion. Never thought of this. Saved me lots of time. Especially the trick of adding to the .bashrc file, neat.</description> <content:encoded><![CDATA[<p>Thanks, these days I am working on some byte level code reading file offsets and I was using a calculator to do this conversion. Never thought of this. Saved me lots of time. Especially the trick of adding to the .bashrc file, neat.</p> ]]></content:encoded> </item> <item><title>By: Peck</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40174</link> <dc:creator>Peck</dc:creator> <pubDate>Sat, 07 Feb 2009 16:24:08 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40174</guid> <description>There&#039;s an error on d2h. It&#039;s ibase=16 to change input format to hex.
This gives the right value AC -&gt; 172</description> <content:encoded><![CDATA[<p>There&#8217;s an error on d2h. It&#8217;s ibase=16 to change input format to hex.<br
/> This gives the right value AC -&gt; 172</p> ]]></content:encoded> </item> <item><title>By: tim</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40173</link> <dc:creator>tim</dc:creator> <pubDate>Sat, 07 Feb 2009 13:11:09 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40173</guid> <description>You can also source your .bashrc file:
. ~/.bashrc</description> <content:encoded><![CDATA[<p>You can also source your .bashrc file:<br
/> . ~/.bashrc</p> ]]></content:encoded> </item> <item><title>By: Vivek Gite</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40172</link> <dc:creator>Vivek Gite</dc:creator> <pubDate>Sat, 07 Feb 2009 12:04:08 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40172</guid> <description>@Sanjeev,
You need to logout and login again so that functions get loaded.
@Loïc Pefferkorn
Thanks for sharing wcalc tool.</description> <content:encoded><![CDATA[<p>@Sanjeev,</p><p>You need to logout and login again so that functions get loaded.</p><p>@Loïc Pefferkorn</p><p>Thanks for sharing wcalc tool.</p> ]]></content:encoded> </item> <item><title>By: sanjeev</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40171</link> <dc:creator>sanjeev</dc:creator> <pubDate>Sat, 07 Feb 2009 11:38:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40171</guid> <description>I tried this but i am not able to do this.
I edited  &lt;em&gt; &quot;~/.bashrc &quot; &lt;/em&gt; file copy and pasted the above code.</description> <content:encoded><![CDATA[<p>I tried this but i am not able to do this.<br
/> I edited <em> &#8220;~/.bashrc &#8221; </em> file copy and pasted the above code.</p> ]]></content:encoded> </item> <item><title>By: Loïc Pefferkorn</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40170</link> <dc:creator>Loïc Pefferkorn</dc:creator> <pubDate>Sat, 07 Feb 2009 11:35:28 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40170</guid> <description>Hello,
Thank you for the tip.
wcalc is also a handy way to do such convertions, and I found it easier to use :
To convert from hex to decimal :
$ echo &quot;0xff&quot;&#124;wcalc -d
= 255
To convert from decimal to hex:
echo &quot;255&quot;&#124;wcalc -h
= 0xff
Binary and octal bases are also handled., and there is a _lot_ of others options !</description> <content:encoded><![CDATA[<p>Hello,<br
/> Thank you for the tip.<br
/> wcalc is also a handy way to do such convertions, and I found it easier to use :</p><p>To convert from hex to decimal :<br
/> $ echo &#8220;0xff&#8221;|wcalc -d<br
/> = 255</p><p>To convert from decimal to hex:<br
/> echo &#8220;255&#8243;|wcalc -h<br
/> = 0xff</p><p>Binary and octal bases are also handled., and there is a _lot_ of others options !</p> ]]></content:encoded> </item> <item><title>By: Amir Watad</title><link>http://www.cyberciti.biz/faq/linux-unix-convert-hex-to-decimal-number/#comment-40161</link> <dc:creator>Amir Watad</dc:creator> <pubDate>Sat, 07 Feb 2009 03:03:40 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/?p=3241#comment-40161</guid> <description>Hi.
A great post. Thank you for sharing.
BTW, a small correction, I think you swapped the function names h2d/d2h by mistake.
Will surely write about this in my blog. will give you the credits of course.
Thanks again.</description> <content:encoded><![CDATA[<p>Hi.<br
/> A great post. Thank you for sharing.</p><p>BTW, a small correction, I think you swapped the function names h2d/d2h by mistake.</p><p>Will surely write about this in my blog. will give you the credits of course.</p><p>Thanks again.</p> ]]></content:encoded> </item> </channel> </rss>
