<?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: shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421437#M767992</link>
    <description>Shell makes only integer calculation. Use bc if you need floating point (see previous answer) is a good idea, since bc is quite universal. However, there might be situations where you do not want to (or you cannot) rely on external programs.&lt;BR /&gt;&lt;BR /&gt;It is possible, though a bit complicated, to do it all in Shell (Posix/Korn, but may work in Bourne too) using a function. I wrote such a function (called fdiv), put in the attachment. For example:&lt;BR /&gt;&lt;BR /&gt;$ fdiv 3 7 3&lt;BR /&gt;0.428&lt;BR /&gt;&lt;BR /&gt;(the 3rd parameter is the number of digits).&lt;BR /&gt;&lt;BR /&gt;Hope it helps,&lt;BR /&gt;Emmanuel</description>
    <pubDate>Wed, 31 May 2000 11:55:54 GMT</pubDate>
    <dc:creator>Emmanuel Eyer</dc:creator>
    <dc:date>2000-05-31T11:55:54Z</dc:date>
    <item>
      <title>shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421433#M767988</link>
      <description>I am trying to get a decimal output from the following.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;let a=50/100&lt;BR /&gt;echo $a&lt;BR /&gt;&lt;BR /&gt;output is 0&lt;BR /&gt;how do I get a 0.50 output?</description>
      <pubDate>Thu, 13 Apr 2000 06:10:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421433#M767988</guid>
      <dc:creator>Jeff Hoevenaar_1</dc:creator>
      <dc:date>2000-04-13T06:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421434#M767989</link>
      <description>Try:&lt;BR /&gt;&lt;BR /&gt;a=`echo "scale=2 ; 50 / 100" | bc`&lt;BR /&gt;echo $a</description>
      <pubDate>Thu, 13 Apr 2000 09:45:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421434#M767989</guid>
      <dc:creator>Paul Hite_2</dc:creator>
      <dc:date>2000-04-13T09:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421435#M767990</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;try formated output with &lt;BR /&gt;&lt;BR /&gt;  printf "%5.2f" $a&lt;BR /&gt;&lt;BR /&gt;see man printf for detailed information&lt;BR /&gt;&lt;BR /&gt;best regards&lt;BR /&gt;Klaus Frank</description>
      <pubDate>Fri, 26 May 2000 14:44:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421435#M767990</guid>
      <dc:creator>Klaus  Frank</dc:creator>
      <dc:date>2000-05-26T14:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421436#M767991</link>
      <description>Hoovey,&lt;BR /&gt;&lt;BR /&gt;Try the following:&lt;BR /&gt;X=$(print|awk '{printf("%.2fn",50/100)}')&lt;BR /&gt;&lt;BR /&gt;This may look ugly, but the awk command is capable of processing floating-point numbers.&lt;BR /&gt;&lt;BR /&gt;Details of the command:&lt;BR /&gt;$() - execute the shell commands within&lt;BR /&gt;awk - awk command&lt;BR /&gt;print - pass awk blank line&lt;BR /&gt;printf - formatted print command&lt;BR /&gt;%.2f - real number 2 places past decimal&lt;BR /&gt;n - newline&lt;BR /&gt;&lt;BR /&gt;Brian&lt;BR /&gt;&amp;lt;*(((&amp;gt;&amp;lt; er&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 31 May 2000 10:43:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421436#M767991</guid>
      <dc:creator>Brian M. Fisher</dc:creator>
      <dc:date>2000-05-31T10:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421437#M767992</link>
      <description>Shell makes only integer calculation. Use bc if you need floating point (see previous answer) is a good idea, since bc is quite universal. However, there might be situations where you do not want to (or you cannot) rely on external programs.&lt;BR /&gt;&lt;BR /&gt;It is possible, though a bit complicated, to do it all in Shell (Posix/Korn, but may work in Bourne too) using a function. I wrote such a function (called fdiv), put in the attachment. For example:&lt;BR /&gt;&lt;BR /&gt;$ fdiv 3 7 3&lt;BR /&gt;0.428&lt;BR /&gt;&lt;BR /&gt;(the 3rd parameter is the number of digits).&lt;BR /&gt;&lt;BR /&gt;Hope it helps,&lt;BR /&gt;Emmanuel</description>
      <pubDate>Wed, 31 May 2000 11:55:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421437#M767992</guid>
      <dc:creator>Emmanuel Eyer</dc:creator>
      <dc:date>2000-05-31T11:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421438#M767993</link>
      <description>you could do this&lt;BR /&gt;&lt;BR /&gt;#! /usr/dt/bin/dtksh&lt;BR /&gt;&lt;BR /&gt;float a   # float is usually aliased to typeset -E&lt;BR /&gt;&lt;BR /&gt;(( a = 50/100 ))&lt;BR /&gt;printf "%fn" $a</description>
      <pubDate>Fri, 14 Jul 2000 15:53:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421438#M767993</guid>
      <dc:creator>curt larson</dc:creator>
      <dc:date>2000-07-14T15:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421439#M767994</link>
      <description>looks like the back slash didn't show up in the printf format statement.&lt;BR /&gt;&lt;BR /&gt;printf "fn" $a&lt;BR /&gt;&lt;BR /&gt;of course the printf supports the usual C syntax of:&lt;BR /&gt;%[flags][field_width][precision][base]conversion</description>
      <pubDate>Fri, 14 Jul 2000 16:04:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421439#M767994</guid>
      <dc:creator>curt larson</dc:creator>
      <dc:date>2000-07-14T16:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421440#M767995</link>
      <description>I dont' why the percent of the backslash isn't showing up.  So I'll put the format into a word format and hope you can understand that better;&lt;BR /&gt;&lt;BR /&gt;printf "(percent)f(backslash)n" $a</description>
      <pubDate>Fri, 14 Jul 2000 16:17:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421440#M767995</guid>
      <dc:creator>curt larson</dc:creator>
      <dc:date>2000-07-14T16:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421441#M767996</link>
      <description>Curt, use (double slash) //&lt;BR /&gt;It is a thing with the forum postin, for front slash to appear, you have to make it double too.&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2000 17:10:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421441#M767996</guid>
      <dc:creator>CHRIS_ANORUO</dc:creator>
      <dc:date>2000-07-14T17:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421442#M767997</link>
      <description>bc -l will give you decimal points in you calculations.&lt;BR /&gt;</description>
      <pubDate>Sat, 15 Jul 2000 14:09:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421442#M767997</guid>
      <dc:creator>CHRIS_ANORUO</dc:creator>
      <dc:date>2000-07-15T14:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421443#M767998</link>
      <description>Do the following to vary your formula and get results in decimal:&lt;BR /&gt;&lt;BR /&gt;# Set scale = # of decimal places you want&lt;BR /&gt;NUMBER="10/5"  # Your formula&lt;BR /&gt;ANSWER=`bc -l &amp;lt;&amp;lt;-EOF&lt;BR /&gt;scale = 2&lt;BR /&gt;${NUMBER}&lt;BR /&gt;EOF`&lt;BR /&gt;&lt;BR /&gt;This should work for you, but the value in ANSWER is text, not number since shell can&lt;BR /&gt;only handle integer values.</description>
      <pubDate>Thu, 27 Jul 2000 16:08:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2421443#M767998</guid>
      <dc:creator>George A Bodnar</dc:creator>
      <dc:date>2000-07-27T16:08:06Z</dc:date>
    </item>
  </channel>
</rss>

