<?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: awk decimal -&amp;gt; hex conversion? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604129#M823205</link>
    <description>Doug,&lt;BR /&gt;&lt;BR /&gt;I can confirm that all 6 of my 11.11 systems came up with exactly the same incorrect answer as yours.  Odd, indeed.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
    <pubDate>Mon, 15 Aug 2005 13:29:55 GMT</pubDate>
    <dc:creator>Pete Randall</dc:creator>
    <dc:date>2005-08-15T13:29:55Z</dc:date>
    <item>
      <title>awk decimal -&gt; hex conversion?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604128#M823204</link>
      <description>Riddle me this, batman!&lt;BR /&gt;&lt;BR /&gt;On all of our 11.11 systems:&lt;BR /&gt;&lt;BR /&gt;# echo "" | awk {printf("%x\n", 1119965980)}'  &lt;BR /&gt;42c1531c # Correct:&lt;BR /&gt;# echo "" | awk '{printf("%x\n", 2482526102)}'&lt;BR /&gt;7fffffff # Incorrect;&lt;BR /&gt;&lt;BR /&gt;On 11.23 systems, it works correctly:&lt;BR /&gt;echo "" | awk '{printf("%x\n", 2482526102)}'&lt;BR /&gt;93f85796 # Correct:&lt;BR /&gt;&lt;BR /&gt;Even on my linux laptop:&lt;BR /&gt;$ echo "" | awk '{printf("%x\n", 2482526102)}'&lt;BR /&gt;93f85796&lt;BR /&gt;&lt;BR /&gt;All kernels are 64 bit where appropriate (obviously not on my linux laptop...)  I tried installing PHCO_29952 w/no success.  Curiously enough, printf works:&lt;BR /&gt;&lt;BR /&gt;# printf "%x\n" 2482526102&lt;BR /&gt;93f85796&lt;BR /&gt;&lt;BR /&gt;Anyone know what might be going on?  Thanks.&lt;BR /&gt;&lt;BR /&gt;Doug&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Aug 2005 13:24:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604128#M823204</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2005-08-15T13:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: awk decimal -&gt; hex conversion?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604129#M823205</link>
      <description>Doug,&lt;BR /&gt;&lt;BR /&gt;I can confirm that all 6 of my 11.11 systems came up with exactly the same incorrect answer as yours.  Odd, indeed.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Mon, 15 Aug 2005 13:29:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604129#M823205</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2005-08-15T13:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: awk decimal -&gt; hex conversion?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604130#M823206</link>
      <description>It appears that somewhere there is a limit.&lt;BR /&gt;&lt;BR /&gt;7fffffff = 2,147,483,647 (or 2^31 - 1)&lt;BR /&gt;&lt;BR /&gt;which is 1 byte short of 2GB (2^31) if one were talking storage space.&lt;BR /&gt;&lt;BR /&gt;If you do your test with:&lt;BR /&gt;&lt;BR /&gt;echo "" | awk '{printf("%x\n",2147483646)'&lt;BR /&gt;&lt;BR /&gt;you get 7ffffffe which is correct.&lt;BR /&gt;&lt;BR /&gt;I can't explain why it is happening or how to fix it though.</description>
      <pubDate>Mon, 15 Aug 2005 13:46:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604130#M823206</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2005-08-15T13:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: awk decimal -&gt; hex conversion?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604131#M823207</link>
      <description>I am thinking that this is coming out of sheel limit of doing arithmatic calculations.&lt;BR /&gt;If I remember correctly, the shell can not do &lt;BR /&gt;anything more than 247xxxxxxxx somthing.&lt;BR /&gt;Which shell are you using.</description>
      <pubDate>Mon, 15 Aug 2005 13:51:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604131#M823207</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-08-15T13:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: awk decimal -&gt; hex conversion?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604132#M823208</link>
      <description>Is your 11.23 system Itanium or PA-RISC?  I just tried the same on my HP-UX 11.23 PA-RISC and I see the same exact behavior as on my 11.11 system (2147483649 is shown as 7fffffff instead of 80000001).&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Aug 2005 13:52:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604132#M823208</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2005-08-15T13:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: awk decimal -&gt; hex conversion?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604133#M823209</link>
      <description>On Itanium 11.23 server it does work correctly. &lt;BR /&gt;with awk. &lt;BR /&gt;&lt;BR /&gt;It does work with printf from within ksh or a posix shell. On an 11.11 machine. &lt;BR /&gt;&lt;BR /&gt;# ksh&lt;BR /&gt;# printf "%x\n" 2482526102&lt;BR /&gt;93f85796&lt;BR /&gt;&lt;BR /&gt;This kinda looks like a awk bug. where it cant handle a number larger than. 2147483647&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Aug 2005 14:08:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604133#M823209</guid>
      <dc:creator>Marvin Strong</dc:creator>
      <dc:date>2005-08-15T14:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: awk decimal -&gt; hex conversion?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604134#M823210</link>
      <description>Whether or not this work will depend upon the native size of an int. You should really plan on everything having the 32-bit limit and always use bc for this kind of conversion if overflow is even remotely possible. Bc supports unlimited precision and size.</description>
      <pubDate>Mon, 15 Aug 2005 15:33:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604134#M823210</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-08-15T15:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: awk decimal -&gt; hex conversion?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604135#M823211</link>
      <description>Hey, all;&lt;BR /&gt;&lt;BR /&gt;Thanks for the replies.  I was thinking it had to do with some kind of limit as well; however, it's not the shell's limit as can be proven by observing the printf statement directly.&lt;BR /&gt;&lt;BR /&gt;I was hoping someone would say "Oh yea; apply this patch".  That doesn't look like it's going to happen though.&lt;BR /&gt;&lt;BR /&gt;Thanks again for the responses.&lt;BR /&gt;&lt;BR /&gt;Doug O'Leary</description>
      <pubDate>Mon, 15 Aug 2005 19:26:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604135#M823211</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2005-08-15T19:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: awk decimal -&gt; hex conversion?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604136#M823212</link>
      <description>Indeed, shells only perform interger arithmetic, 32 bits only, regardless of what the kernel is doing. The kernel never sees any of this and it's important to isolate what pieces are handled by the shell and by processes. So in assigning a number to a variable, you can certainly do something like this:&lt;BR /&gt; &lt;BR /&gt;x=2482526102&lt;BR /&gt;echo $x&lt;BR /&gt;2482526102&lt;BR /&gt; &lt;BR /&gt;but force the variable to be integer only:&lt;BR /&gt; &lt;BR /&gt;typeset x=2482526102&lt;BR /&gt;echo $x&lt;BR /&gt;-1812441194&lt;BR /&gt; &lt;BR /&gt;This is because untyped variables start as strings and if used in arithmetic calculations, the equivalent integer value is used. The best way to avoid problems like this is to perform the calculations in bc (and you can convert decimal, octal, hex, etc) and be careful about using shell variables for calculations. If the variable is used as a string and passed to bc, the results will be accurate.</description>
      <pubDate>Mon, 15 Aug 2005 19:46:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/awk-decimal-gt-hex-conversion/m-p/3604136#M823212</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-08-15T19:46:55Z</dc:date>
    </item>
  </channel>
</rss>

