<?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: Converting hex string to integer in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084893#M811604</link>
    <description>Here is one approach leveraging bc although Perl or awk would be easy as well.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;IN="2bc"&lt;BR /&gt;OUT=$(echo "obase=10; ibase=16; $(echo ${IN} | tr '[a-f]' '[A-F]')" | bc)&lt;BR /&gt;echo "IN = ${IN}  OUT = ${OUT}"&lt;BR /&gt;&lt;BR /&gt;Now, If I didn't miss any paren's that should work like a champ. Man bc for details. Note: bc expect hex digits to be uppercase hence the use of 'tr'.&lt;BR /&gt;</description>
    <pubDate>Fri, 03 Oct 2003 08:42:31 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2003-10-03T08:42:31Z</dc:date>
    <item>
      <title>Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084890#M811601</link>
      <description>Does anybody has a script to convert a hex string to its integer equivalence ?&lt;BR /&gt;E.G. 2bc (string) = 700 (integer) &lt;BR /&gt;&lt;BR /&gt;Thanks, Ed</description>
      <pubDate>Fri, 03 Oct 2003 08:29:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084890#M811601</guid>
      <dc:creator>Ed Kwan_2</dc:creator>
      <dc:date>2003-10-03T08:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084891#M811602</link>
      <description>I usually use ADB if I need it quick.&lt;BR /&gt;&lt;BR /&gt;adb&lt;BR /&gt;0x2bc=D&lt;BR /&gt;$q&lt;BR /&gt;&lt;BR /&gt;best regards,&lt;BR /&gt;&lt;BR /&gt;Kent M. Ostby&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Oct 2003 08:35:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084891#M811602</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2003-10-03T08:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084892#M811603</link>
      <description>Hi,&lt;BR /&gt;# printf %d\\n 0x2bc&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Oct 2003 08:36:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084892#M811603</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-10-03T08:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084893#M811604</link>
      <description>Here is one approach leveraging bc although Perl or awk would be easy as well.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;IN="2bc"&lt;BR /&gt;OUT=$(echo "obase=10; ibase=16; $(echo ${IN} | tr '[a-f]' '[A-F]')" | bc)&lt;BR /&gt;echo "IN = ${IN}  OUT = ${OUT}"&lt;BR /&gt;&lt;BR /&gt;Now, If I didn't miss any paren's that should work like a champ. Man bc for details. Note: bc expect hex digits to be uppercase hence the use of 'tr'.&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Oct 2003 08:42:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084893#M811604</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-10-03T08:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084894#M811605</link>
      <description>&lt;A href="http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x2f6c9c196a4bd71190080090279cd0f9%2C00.html&amp;amp;admit=716493758+1065188507585+28353475" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x2f6c9c196a4bd71190080090279cd0f9%2C00.html&amp;amp;admit=716493758+1065188507585+28353475&lt;/A&gt;</description>
      <pubDate>Fri, 03 Oct 2003 08:42:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084894#M811605</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2003-10-03T08:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084895#M811606</link>
      <description>Thank you gentlemen.&lt;BR /&gt;&lt;BR /&gt;However, I need to call this over and over again.  I tried the following but comes back with a conversion error:&lt;BR /&gt;&lt;BR /&gt;a=2bc&lt;BR /&gt;b=`printf %d\n $a`&lt;BR /&gt;echo $b&lt;BR /&gt;&lt;BR /&gt;I need to use variable b as a string in other parts of my script.&lt;BR /&gt;&lt;BR /&gt;Thanks, Ed</description>
      <pubDate>Fri, 03 Oct 2003 08:43:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084895#M811606</guid>
      <dc:creator>Ed Kwan_2</dc:creator>
      <dc:date>2003-10-03T08:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084896#M811607</link>
      <description>the script:&lt;BR /&gt;---------------------&lt;BR /&gt;#! /bin/sh&lt;BR /&gt;H=$1&lt;BR /&gt;typeset -i10 D=16#$H&lt;BR /&gt;echo $D&lt;BR /&gt;&lt;BR /&gt;---------------------&lt;BR /&gt;&lt;BR /&gt;Call the script:&lt;BR /&gt;./script 2bc&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Sergejs&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Oct 2003 08:43:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084896#M811607</guid>
      <dc:creator>Sergejs Svitnevs</dc:creator>
      <dc:date>2003-10-03T08:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084897#M811608</link>
      <description>#let i=16#2bc&lt;BR /&gt;#echo $i&lt;BR /&gt;700</description>
      <pubDate>Fri, 03 Oct 2003 08:48:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084897#M811608</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-10-03T08:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084898#M811609</link>
      <description>Hi again,&lt;BR /&gt;try this:&lt;BR /&gt; &lt;BR /&gt;a=2bc&lt;BR /&gt;b=$(printf %d\\n 0x${a})&lt;BR /&gt;echo $b&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Fri, 03 Oct 2003 08:51:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084898#M811609</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-10-03T08:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084899#M811610</link>
      <description>Ok then, as a script, save the following as (eg) x2i.sh:&lt;BR /&gt;&lt;BR /&gt;#/bin/sh&lt;BR /&gt;let i=16#$1&lt;BR /&gt;echo $i&lt;BR /&gt;&lt;BR /&gt;#chmod u+x x2i.sj&lt;BR /&gt;Call it thus:&lt;BR /&gt;#x2i.sh 2bc&lt;BR /&gt;700</description>
      <pubDate>Fri, 03 Oct 2003 08:52:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084899#M811610</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-10-03T08:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084900#M811611</link>
      <description>if u have CDE(Running ReflexionX or Humming Bird)&lt;BR /&gt;#/usr/dt/bin/dtcalc&lt;BR /&gt;Sorry folks ! for being NON TECHNICAL :-)&lt;BR /&gt;think everybody her will excuse me</description>
      <pubDate>Fri, 03 Oct 2003 08:53:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084900#M811611</guid>
      <dc:creator>Hari Kumar</dc:creator>
      <dc:date>2003-10-03T08:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084901#M811612</link>
      <description>Thank you very much for all the help. I now have multiple ways to do it.</description>
      <pubDate>Fri, 03 Oct 2003 08:57:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084901#M811612</guid>
      <dc:creator>Ed Kwan_2</dc:creator>
      <dc:date>2003-10-03T08:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084902#M811613</link>
      <description>echo "ibase=16;2BC"|bc&lt;BR /&gt;&lt;BR /&gt;This sets the input base for bc to hex, the default output is decimal.  You can convert to octal and binary (or trinary, quadrary{?},&lt;BR /&gt; etc) by changing the argument to ibase.  Go the other way by changing the obase or output base: echo "obase=16;700"|bc.&lt;BR /&gt;Note that if you set the ibase to a number, and want to change either the ibase or obase afterwards, you'll need to give the argument to that command in the form it is expecting it--not necessarily decimal.</description>
      <pubDate>Fri, 03 Oct 2003 09:29:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084902#M811613</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2003-10-03T09:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Converting hex string to integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084903#M811614</link>
      <description>Here's a quick little shell script exercise I just hacked out.  It shows the outputs in decimal, octal, hexadecimal, binary, and ASCII. (no point necessary, I just did this for the halibut)&lt;BR /&gt;NUM=1&lt;BR /&gt;while test "$NUM" -le "256"&lt;BR /&gt;do&lt;BR /&gt;        echo "$NUM \c"&lt;BR /&gt;        HNUM=`echo "obase=16;$NUM"|bc`&lt;BR /&gt;        ONUM=`echo "obase=8;$NUM"|bc`&lt;BR /&gt;        BNUM=`echo "obase=2;$NUM"|bc`&lt;BR /&gt;        if test "$NUM" -ge "32" -a "$NUM" -le "127"&lt;BR /&gt;        then&lt;BR /&gt;                ASCII=`echo "\0$ONUM"`&lt;BR /&gt;        else&lt;BR /&gt;                ASCII=""&lt;BR /&gt;        fi&lt;BR /&gt;        echo "$HNUM $ONUM $BNUM $ASCII"&lt;BR /&gt;        (( NUM = "$NUM" + "1" ))&lt;BR /&gt;done</description>
      <pubDate>Fri, 03 Oct 2003 09:53:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/converting-hex-string-to-integer/m-p/3084903#M811614</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2003-10-03T09:53:17Z</dc:date>
    </item>
  </channel>
</rss>

