Re: how to calculate fractions with let?

samuels_at_red.seas.upenn.edu
Date: 03/21/05

  • Next message: Rouben Rostamian: "Re: how to calculate fractions with let?"
    Date: Mon, 21 Mar 2005 18:03:31 +0000 (UTC)
    
    

    thanks :-)

    Chris F.A. Johnson (cfajohnson@gmail.com) wrote:
    : On Mon, 21 Mar 2005 at 17:37 GMT, samuels@red.seas.upenn.edu () wrote:
    : > hi,
    : > for the arithmetic expression 7/3, what unix function/command will
    : > show me the correct value of 2.33 and not just 2 like let?

    : Most shells do not support fractional arithmetic (ksh93 is an
    : exception).

    : You need to use an external command such as awk or bc.

    : For example, I use this function:

    : calc()
    : {
    : awk 'BEGIN { OFMT="%f"; print '"$*"'; exit}'
    : }

    : Once it's defined you can use:

    : $ calc 7/3
    : 2.333333

    : --
    : Chris F.A. Johnson http://cfaj.freeshell.org/shell
    : ===================================================================
    : My code (if any) in this post is copyright 2005, Chris F.A. Johnson
    : and may be copied under the terms of the GNU General Public License


  • Next message: Rouben Rostamian: "Re: how to calculate fractions with let?"