<?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: Division Operation in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492019#M845205</link>
    <description>Gilbert,&lt;BR /&gt;&lt;BR /&gt;One of the method you can use is.&lt;BR /&gt;&lt;BR /&gt;touch /tmp/anyfile&lt;BR /&gt;export m=7&lt;BR /&gt;export n=2&lt;BR /&gt;cat /tmp/anyfile | awk '{print '$m'/'$n'}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 23 Feb 2005 11:42:47 GMT</pubDate>
    <dc:creator>Rajeev Tyagi</dc:creator>
    <dc:date>2005-02-23T11:42:47Z</dc:date>
    <item>
      <title>Division Operation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492017#M845203</link>
      <description>how do i set precision of a result ?  At command line:&lt;BR /&gt;#let m=7&lt;BR /&gt;#let n=2&lt;BR /&gt;#let r=$m/$n&lt;BR /&gt;#echo $r&lt;BR /&gt;3&lt;BR /&gt;&lt;BR /&gt;Only want the integer portion of calc so this is result needed.&lt;BR /&gt;&lt;BR /&gt;How to guarantee that when run code on an arbitrary UNIX box it's going to return same precision ?  How to incorporate precision of result into the code ?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Feb 2005 11:30:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492017#M845203</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2005-02-23T11:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Division Operation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492018#M845204</link>
      <description>Shell arithmatic oprations are not precise and has limitations.&lt;BR /&gt;&lt;BR /&gt;You can do "echo "4/3"|bc"&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Wed, 23 Feb 2005 11:40:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492018#M845204</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-02-23T11:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Division Operation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492019#M845205</link>
      <description>Gilbert,&lt;BR /&gt;&lt;BR /&gt;One of the method you can use is.&lt;BR /&gt;&lt;BR /&gt;touch /tmp/anyfile&lt;BR /&gt;export m=7&lt;BR /&gt;export n=2&lt;BR /&gt;cat /tmp/anyfile | awk '{print '$m'/'$n'}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Feb 2005 11:42:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492019#M845205</guid>
      <dc:creator>Rajeev Tyagi</dc:creator>
      <dc:date>2005-02-23T11:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: Division Operation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492020#M845206</link>
      <description>You don't need to concern yourself at all because all shell arithmatic is integer (there is one shell that can do floating-point math but you must be explicit in your shell commands) and thus all will truncate (not round) the result.&lt;BR /&gt;&lt;BR /&gt;It's generally considered better form to type your variables so that&lt;BR /&gt;&lt;BR /&gt;typeset -i m=7&lt;BR /&gt;is better than &lt;BR /&gt;let m=7&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Feb 2005 11:54:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492020#M845206</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-23T11:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Division Operation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492021#M845207</link>
      <description>Got it.  Much appreciated!&lt;BR /&gt;echo "scale=0; 10/3" | bc&lt;BR /&gt;3&lt;BR /&gt;echo "scale=2; 10/3" | bc&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Feb 2005 11:54:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492021#M845207</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2005-02-23T11:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Division Operation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492022#M845208</link>
      <description>You really don't have it. There is no reason to call the external utility bc (or awk, Perl) because the shell can only do integer math. It's already done it for you. Your original approach is perfectly portable. The times that external programs like bc are called are those in which non-integer math are needed.</description>
      <pubDate>Wed, 23 Feb 2005 12:21:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492022#M845208</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-23T12:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Division Operation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492023#M845209</link>
      <description>Had replied before seeing your post, see now that integer math is the default, which is good for me.&lt;BR /&gt;&lt;BR /&gt;Regarding your pointer on the uses of "let" vs. "typeset" what are the advantages of "typeset" :-)&lt;BR /&gt;&lt;BR /&gt;here's a related question:&lt;BR /&gt;&lt;BR /&gt;typeset -i p=50&lt;BR /&gt;typeset -i q=$p&lt;BR /&gt;typeset -i r=1&lt;BR /&gt;&lt;BR /&gt;Have made the change you suggested for my uses of "let" but when "read" is used, what are the implications ?  Is there a way to sort of use "typeset" when using "read" at the end of a string of piped ops ?&lt;BR /&gt;&lt;BR /&gt;ls | wc -l | sed 's/^[ \t]*//;s/[ \t]*$//' | read histfilect&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Feb 2005 12:28:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492023#M845209</guid>
      <dc:creator>Gilbert Standen_1</dc:creator>
      <dc:date>2005-02-23T12:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Division Operation</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492024#M845210</link>
      <description>Yes, simply  put the typeset in another statement.&lt;BR /&gt;&lt;BR /&gt;typeset -i histfileect=0&lt;BR /&gt;ls | wc -l | sed 's/^[ \t]*//;s/[ \t]*$//' | read histfilect &lt;BR /&gt;&lt;BR /&gt;The typeset applies to all following references of the variable.</description>
      <pubDate>Wed, 23 Feb 2005 12:35:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/division-operation/m-p/3492024#M845210</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-02-23T12:35:05Z</dc:date>
    </item>
  </channel>
</rss>

