<?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: Calculation in Ksh ! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026592#M131691</link>
    <description>In a word, no. All shell arithmatic is integer not floating point. You can easily use bc, awk, or Perl to do this calculations and return them to the shell.&lt;BR /&gt;&lt;BR /&gt;A Forums search will reveal many different approaches.&lt;BR /&gt;</description>
    <pubDate>Thu, 17 Jul 2003 15:06:49 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2003-07-17T15:06:49Z</dc:date>
    <item>
      <title>Calculation in Ksh !</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026591#M131690</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I am just wondering whether I can do decimal calculation in Ksh environment !!&lt;BR /&gt;&lt;BR /&gt;I have tried to calcuate 10/100 in Ksh and the result will be integer 0&lt;BR /&gt;&lt;BR /&gt;Can I create and control the number of decimal point e.g. 0.1 or 0.10 for the above calcuation ??&lt;BR /&gt;&lt;BR /&gt;Many thanks&lt;BR /&gt;&lt;BR /&gt;Chris,</description>
      <pubDate>Thu, 17 Jul 2003 15:02:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026591#M131690</guid>
      <dc:creator>Chris Fung</dc:creator>
      <dc:date>2003-07-17T15:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation in Ksh !</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026592#M131691</link>
      <description>In a word, no. All shell arithmatic is integer not floating point. You can easily use bc, awk, or Perl to do this calculations and return them to the shell.&lt;BR /&gt;&lt;BR /&gt;A Forums search will reveal many different approaches.&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Jul 2003 15:06:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026592#M131691</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-07-17T15:06:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation in Ksh !</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026593#M131692</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;Using 'bc' is easy and offers a choice of the input and output base, scale and length of output.  For instance:&lt;BR /&gt;&lt;BR /&gt;# X=`echo "ibase=16;F+F;obase=10"|bc`;echo ${X}&lt;BR /&gt;&lt;BR /&gt;# Y=`echo "scale=3;1/8"|bc`;echo ${Y}&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 17 Jul 2003 15:16:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026593#M131692</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-07-17T15:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation in Ksh !</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026594#M131693</link>
      <description>Chris,&lt;BR /&gt;Though it would be best to get used to using the utilities previously mentioned, in a down and dirty, simply multiply by 100.&lt;BR /&gt;I have done this quite often in simple scripts then set the decimal point to get percentages, etc.&lt;BR /&gt;&lt;BR /&gt;Best of luck.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;dl&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Jul 2003 16:14:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026594#M131693</guid>
      <dc:creator>Dave La Mar</dc:creator>
      <dc:date>2003-07-17T16:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation in Ksh !</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026595#M131694</link>
      <description>Mr. Stephenson is pretty much right (All shell arithmatic is integer not floating point).  But, not absolutely.  only korn shell versions newer then the 11/16/88 version have floating point arithmetic.  unfortunately for you /usr/bin/ksh is the 11/16/88 version.&lt;BR /&gt;&lt;BR /&gt;but /usr/dt/bin/dtksh does include most of the 93 version of the korn shell features including floating point arithmetic. So you &lt;BR /&gt;can do something like this if you like.&lt;BR /&gt;&lt;BR /&gt;#!/usr/dt/bin/dtksh&lt;BR /&gt;&lt;BR /&gt;typeset -F a=3 b=4 c  # specify the floating point attribute&lt;BR /&gt;&lt;BR /&gt;c=$(( $a/$b ))&lt;BR /&gt;print $c&lt;BR /&gt;&lt;BR /&gt;#or&lt;BR /&gt;printf "%4.3f\n" $(( $a/$b ))</description>
      <pubDate>Thu, 17 Jul 2003 16:28:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026595#M131694</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-07-17T16:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation in Ksh !</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026596#M131695</link>
      <description>No....&lt;BR /&gt;&lt;BR /&gt;try awk&lt;BR /&gt;&lt;BR /&gt;a=10&lt;BR /&gt;b=100&lt;BR /&gt;c=$(echo $a $b | awk '{print $1/$2}')&lt;BR /&gt;echo $c&lt;BR /&gt;&lt;BR /&gt;If you want to format the output&lt;BR /&gt;c=$(echo $a $b | awk '{printf "%10.2f", $a/$b}')&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Tim</description>
      <pubDate>Thu, 17 Jul 2003 16:49:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026596#M131695</guid>
      <dc:creator>Tim D Fulford</dc:creator>
      <dc:date>2003-07-17T16:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculation in Ksh !</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026597#M131696</link>
      <description>ksh93 can do floating-point arithmetic.</description>
      <pubDate>Thu, 17 Jul 2003 17:19:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/calculation-in-ksh/m-p/3026597#M131696</guid>
      <dc:creator>Elena Leontieva</dc:creator>
      <dc:date>2003-07-17T17:19:05Z</dc:date>
    </item>
  </channel>
</rss>

