<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: convert hexa to decimal values in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976613#M95498</link>
    <description>HP 11.11 here.&lt;BR /&gt;#bc&lt;BR /&gt;ib=16&lt;BR /&gt;FFFFF000&lt;BR /&gt;4294963200&lt;BR /&gt;^D&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;If you're converting not to many numbers, you could try&lt;BR /&gt;&lt;BR /&gt;#perl -e '$x=0xFFFFF000;print "$x\n"'&lt;BR /&gt;429496320&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;If it's a very few numbers, you can go to basics:&lt;BR /&gt;&lt;BR /&gt;FFFFF000 = FFFFFFFF - FFF&lt;BR /&gt;&lt;BR /&gt;FFFFFFFF is one less than x100000000, which is 16^8 (=4294967296), or 4294967295&lt;BR /&gt;&lt;BR /&gt;FFF is one less than x1000 (4095)&lt;BR /&gt;&lt;BR /&gt;4294967295 - 4095 = 4294963200&lt;BR /&gt;&lt;BR /&gt;Or even:&lt;BR /&gt;16^8 - 16^3 = 4294963200&lt;BR /&gt;&lt;BR /&gt;(In hex, that's&lt;BR /&gt;100000000 - 1000 = 0xFFFFF000)&lt;BR /&gt;&lt;BR /&gt;Here's a short perl routine:&lt;BR /&gt;&lt;BR /&gt;$!/usr/bin/perl&lt;BR /&gt;while (&lt;STDIN&gt;) {&lt;BR /&gt;  print hex "$_"; print "\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;(For some odd reason, this doesn't work:&lt;BR /&gt;   print hex "$_\n";&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;and you can always change &lt;STDIN&gt; to read from a file.&lt;BR /&gt;&lt;/STDIN&gt;&lt;/STDIN&gt;</description>
    <pubDate>Mon, 09 Apr 2007 11:00:54 GMT</pubDate>
    <dc:creator>Michael D. Zorn</dc:creator>
    <dc:date>2007-04-09T11:00:54Z</dc:date>
    <item>
      <title>convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976603#M95488</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;i'm trying to convert an hexadicimal value to decimal but it seems impossible with my knowledge. ;)&lt;BR /&gt;&lt;BR /&gt;that's what i tried (under ksh).&lt;BR /&gt;HPUX B.11.00:&lt;BR /&gt;# echo 0xfffff000=D |adb&lt;BR /&gt;                -4096&lt;BR /&gt;# printf "%d\n" 0xfffff000&lt;BR /&gt;printf:  Error converting 0xfffff000&lt;BR /&gt;2147483647&lt;BR /&gt;# print - $((16#fffff000))&lt;BR /&gt;-4096&lt;BR /&gt;# echo "obase=86 0xfffff000" |bc -l&lt;BR /&gt;syntax error on line 1, /usr/lib/lib.b&lt;BR /&gt;# echo "obase=86 ; fffff000" |bc&lt;BR /&gt;syntax error on line 1&lt;BR /&gt;# echo "fffff000" |tr "[[:xdigit:]]" "[[:digit:]]"  &lt;BR /&gt;tr: String2 contains an invalid character class.&lt;BR /&gt;&lt;BR /&gt;i've the same errors in HP-UX B.11.11/B.11.23&lt;BR /&gt;&lt;BR /&gt;i need to convert these values for a script so, do you have advice for it ?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Cedrick Gaillard&lt;BR /&gt;</description>
      <pubDate>Fri, 06 Apr 2007 08:01:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976603#M95488</guid>
      <dc:creator>mobidyc</dc:creator>
      <dc:date>2007-04-06T08:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976604#M95489</link>
      <description>You can use this one liner:&lt;BR /&gt;$ typeset -i10 x=16#fffff000; echo $x&lt;BR /&gt;(This returns an unsigned int for 11.23 and 11.31 ksh.  sh returns -4096.)&lt;BR /&gt;&lt;BR /&gt;What was wrong with your adb and $(( )) solutions?</description>
      <pubDate>Fri, 06 Apr 2007 08:12:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976604#M95489</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-04-06T08:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976605#M95490</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;There's nothing wrong with your methodology, only that your numbers exceed 32-bit integers.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 06 Apr 2007 08:13:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976605#M95490</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-04-06T08:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976606#M95491</link>
      <description>thanks for your answers,&lt;BR /&gt;&lt;BR /&gt;i know now that this is because my numbers exceed 32-bit integers.&lt;BR /&gt;&lt;BR /&gt;do you have a solution for convert these values correctly ?&lt;BR /&gt;my system is 64bits, is there a 64bit binary who can calculate the result?&lt;BR /&gt;&lt;BR /&gt;the result of 0xfffff000 would be 4294963200, not -4096&lt;BR /&gt;&lt;BR /&gt;and why</description>
      <pubDate>Fri, 06 Apr 2007 08:48:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976606#M95491</guid>
      <dc:creator>mobidyc</dc:creator>
      <dc:date>2007-04-06T08:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976607#M95492</link>
      <description>bc is your friend. Although ksh93 does exist on HP-UX (skillfully hidden away in /usr/dt/bin/dtksh) it is also limited to 32 bit  numbers. bc can handle large numbers:&lt;BR /&gt; &lt;BR /&gt;$ echo "4294963200*1234.234"|bc&lt;BR /&gt;5300989610188.800</description>
      <pubDate>Fri, 06 Apr 2007 08:58:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976607#M95492</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2007-04-06T08:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976608#M95493</link>
      <description>Hi (again) Cedrick:&lt;BR /&gt;&lt;BR /&gt;In the shell, using 'bc' is an easy way:&lt;BR /&gt;&lt;BR /&gt;# echo "obase=10;ibase=16;FFFFF000"|bc&lt;BR /&gt;&lt;BR /&gt;...note the uppercase hexadecimal digits.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 06 Apr 2007 09:06:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976608#M95493</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-04-06T09:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976609#M95494</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;as indicated behind, i've tried bc, maybe with a wrong syntax:&lt;BR /&gt;&lt;BR /&gt;# echo "obase=86 ; fffff000/1024/1024" |bc&lt;BR /&gt;syntax error on line 1,&lt;BR /&gt;&lt;BR /&gt;i've just looking something, at home i've a linux, it have a 32bit processor however, it can convert without problem so, where is the limitation ?&lt;BR /&gt;&lt;BR /&gt;$&amp;gt; uname -s ; printf "%d\n" 0xfffff000&lt;BR /&gt;Linux&lt;BR /&gt;4294963200&lt;BR /&gt;&lt;BR /&gt;# uname -s ; printf "%d\n" 0xfffff000&lt;BR /&gt;HP-UX&lt;BR /&gt;printf:  Error converting 0xfffff000&lt;BR /&gt;2147483647&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Cedrick Gaillard</description>
      <pubDate>Fri, 06 Apr 2007 09:10:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976609#M95494</guid>
      <dc:creator>mobidyc</dc:creator>
      <dc:date>2007-04-06T09:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976610#M95495</link>
      <description>Hi (again) Cedrick:&lt;BR /&gt;&lt;BR /&gt;Use UPPERCASE hexadecimal digits with 'bc' as I showed above.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 06 Apr 2007 09:27:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976610#M95495</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-04-06T09:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976611#M95496</link>
      <description>Big thanks James,&lt;BR /&gt;&lt;BR /&gt;the uppercase letter give me no errors from bc now and correct my [io]base variables has gived to me a good result.&lt;BR /&gt;&lt;BR /&gt;problem is solved, thanks ;)&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Cedrick Gaillard</description>
      <pubDate>Fri, 06 Apr 2007 09:29:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976611#M95496</guid>
      <dc:creator>mobidyc</dc:creator>
      <dc:date>2007-04-06T09:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976612#M95497</link>
      <description>&amp;gt;at home i've a linux, it have a 32bit processor however, it can convert without problem so, where is the limitation?&lt;BR /&gt;&lt;BR /&gt;Does it handle arbitrary 64 bit numbers?  Like the 11.23 ksh?&lt;BR /&gt;&lt;BR /&gt;I guess it depends on the standard and whether it is worth it to extend it to long longs.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 06 Apr 2007 19:17:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976612#M95497</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-04-06T19:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976613#M95498</link>
      <description>HP 11.11 here.&lt;BR /&gt;#bc&lt;BR /&gt;ib=16&lt;BR /&gt;FFFFF000&lt;BR /&gt;4294963200&lt;BR /&gt;^D&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;If you're converting not to many numbers, you could try&lt;BR /&gt;&lt;BR /&gt;#perl -e '$x=0xFFFFF000;print "$x\n"'&lt;BR /&gt;429496320&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;If it's a very few numbers, you can go to basics:&lt;BR /&gt;&lt;BR /&gt;FFFFF000 = FFFFFFFF - FFF&lt;BR /&gt;&lt;BR /&gt;FFFFFFFF is one less than x100000000, which is 16^8 (=4294967296), or 4294967295&lt;BR /&gt;&lt;BR /&gt;FFF is one less than x1000 (4095)&lt;BR /&gt;&lt;BR /&gt;4294967295 - 4095 = 4294963200&lt;BR /&gt;&lt;BR /&gt;Or even:&lt;BR /&gt;16^8 - 16^3 = 4294963200&lt;BR /&gt;&lt;BR /&gt;(In hex, that's&lt;BR /&gt;100000000 - 1000 = 0xFFFFF000)&lt;BR /&gt;&lt;BR /&gt;Here's a short perl routine:&lt;BR /&gt;&lt;BR /&gt;$!/usr/bin/perl&lt;BR /&gt;while (&lt;STDIN&gt;) {&lt;BR /&gt;  print hex "$_"; print "\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;(For some odd reason, this doesn't work:&lt;BR /&gt;   print hex "$_\n";&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;and you can always change &lt;STDIN&gt; to read from a file.&lt;BR /&gt;&lt;/STDIN&gt;&lt;/STDIN&gt;</description>
      <pubDate>Mon, 09 Apr 2007 11:00:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976613#M95498</guid>
      <dc:creator>Michael D. Zorn</dc:creator>
      <dc:date>2007-04-09T11:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976614#M95499</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;If you wish to use Perl's 'hex' function you can do:&lt;BR /&gt;&lt;BR /&gt;# echo FF|perl -nle 'print hex'   &lt;BR /&gt;255&lt;BR /&gt;&lt;BR /&gt;(or):&lt;BR /&gt;&lt;BR /&gt;# perl -le 'print hex $ARGV[0]' FFFF&lt;BR /&gt;65535&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 09 Apr 2007 11:07:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976614#M95499</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-04-09T11:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: convert hexa to decimal values</title>
      <link>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976615#M95500</link>
      <description>As for the Perl variants,&lt;BR /&gt;if you give it as a literal there's even no need for a call of oct() or hex(). &lt;BR /&gt;&lt;BR /&gt;$ perl -le 'print 0xfffff000'&lt;BR /&gt;4294963200&lt;BR /&gt;&lt;BR /&gt;Obviously, this doesn't work anymore if read from stdin or a file.&lt;BR /&gt;&lt;BR /&gt;$ perl -le 'print shift' 0xfffff000 &lt;BR /&gt;0xfffff000&lt;BR /&gt;&lt;BR /&gt;then you have to use oct or hex&lt;BR /&gt;&lt;BR /&gt;$ perl -le 'print hex shift' 0xfffff000&lt;BR /&gt;4294963200&lt;BR /&gt;&lt;BR /&gt;$ perl -le 'print oct shift' 0xfffff000&lt;BR /&gt;4294963200&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 10 Apr 2007 04:13:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/convert-hexa-to-decimal-values/m-p/3976615#M95500</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-04-10T04:13:31Z</dc:date>
    </item>
  </channel>
</rss>

