<?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: Scripting issue in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992985#M95959</link>
    <description>&amp;gt;HGH: Shell does only integer math.&lt;BR /&gt;&lt;BR /&gt;You can simulate it by multiplying the numerator by 10 to the power of the number of fractional digits, then manually placing the decimal point.&lt;BR /&gt;&lt;BR /&gt;Of course this won't work well if the number overflows before the divide.</description>
    <pubDate>Thu, 03 May 2007 23:44:07 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2007-05-03T23:44:07Z</dc:date>
    <item>
      <title>Scripting issue</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992980#M95954</link>
      <description>Hi All, &lt;BR /&gt;&lt;BR /&gt;I want to calculate the space using a script. When I used some command below, it gave me result 0.&lt;BR /&gt;&lt;BR /&gt;PCT=44&lt;BR /&gt;USED=45260.8&lt;BR /&gt;((FLOATPCT=PCT / 100))&lt;BR /&gt;((TOTUSED=$FLOATPCT * $USED))&lt;BR /&gt;echo $FLOATPCT&lt;BR /&gt;echo $TOTUSED&lt;BR /&gt;&lt;BR /&gt;Both was giving me 0 result. How can I modify the script, so the result of FLOATPCT=0.44 and TOTUSED=19914.752 instead?&lt;BR /&gt;&lt;BR /&gt;Pls help. &lt;BR /&gt;&lt;BR /&gt;Thanks and Best Regards,&lt;BR /&gt;Negara&lt;BR /&gt;</description>
      <pubDate>Thu, 03 May 2007 03:34:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992980#M95954</guid>
      <dc:creator>Dewa Negara_4</dc:creator>
      <dc:date>2007-05-03T03:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting issue</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992981#M95955</link>
      <description>Hi Negara&lt;BR /&gt;&lt;BR /&gt;Shell does only integer math.&lt;BR /&gt;&lt;BR /&gt;You may try someting like this:&lt;BR /&gt;&lt;BR /&gt;# echo "scale=2 ; $PCT/100" | bc&lt;BR /&gt;.44&lt;BR /&gt;&lt;BR /&gt;uxmp0001:/root# echo "scale=2 ; $PCT/100*$USED" | bc&lt;BR /&gt;19914.75&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rgds&lt;BR /&gt;HGH&lt;BR /&gt;</description>
      <pubDate>Thu, 03 May 2007 03:56:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992981#M95955</guid>
      <dc:creator>Hemmetter</dc:creator>
      <dc:date>2007-05-03T03:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting issue</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992982#M95956</link>
      <description>Hi Negra:&lt;BR /&gt;&lt;BR /&gt;Another way is to use 'swk':&lt;BR /&gt;&lt;BR /&gt;# awk -v PCT=44 -v USED=45260.8 'BEGIN{printf("%.2f\n",(PCT/100)*USED)}' &lt;BR /&gt;&lt;BR /&gt;19914.75&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 03 May 2007 06:49:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992982#M95956</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-03T06:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting issue</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992983#M95957</link>
      <description>The ksh and POSIX shells on HP-UX have only integer math, no floating point. The ksh on HP-UX is ksh-1988 and the POSIX shell is based on the same code. You need ksh-1993. Change your script interpreter to use /usr/dt/bin/dtksh as your shell interpreter. Also, you cannot use integer numbers and expect them to be converted to floating point. Change your script to read like this:&lt;BR /&gt; &lt;BR /&gt;#!/usr/dt/bin/dtksh&lt;BR /&gt;typeset -F PCT=44.0&lt;BR /&gt;typeset -F USED=45260.8&lt;BR /&gt;((FLOATPCT=PCT / 100))&lt;BR /&gt;((TOTUSED=$FLOATPCT * $USED))&lt;BR /&gt;echo $FLOATPCT&lt;BR /&gt;echo $TOTUSED&lt;BR /&gt; &lt;BR /&gt;This now gives you the expected answers. Unfortunately, the HP man page for dtksh covers mostly the Xwindow enhancements and doesn't talk at all about typeset and integer versus floating point variables and math. Use this as your dtksh resource page:&lt;BR /&gt; &lt;BR /&gt;&lt;A href="http://www.kornshell.com/doc/" target="_blank"&gt;http://www.kornshell.com/doc/&lt;/A&gt;</description>
      <pubDate>Thu, 03 May 2007 10:14:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992983#M95957</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2007-05-03T10:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting issue</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992984#M95958</link>
      <description>Hi All, &lt;BR /&gt;&lt;BR /&gt;Thanks alot for your help. It's clear for me now. &lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Negara</description>
      <pubDate>Thu, 03 May 2007 21:53:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992984#M95958</guid>
      <dc:creator>Dewa Negara_4</dc:creator>
      <dc:date>2007-05-03T21:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting issue</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992985#M95959</link>
      <description>&amp;gt;HGH: Shell does only integer math.&lt;BR /&gt;&lt;BR /&gt;You can simulate it by multiplying the numerator by 10 to the power of the number of fractional digits, then manually placing the decimal point.&lt;BR /&gt;&lt;BR /&gt;Of course this won't work well if the number overflows before the divide.</description>
      <pubDate>Thu, 03 May 2007 23:44:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-issue/m-p/3992985#M95959</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-05-03T23:44:07Z</dc:date>
    </item>
  </channel>
</rss>

