Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!mailrus!husc6!im4u!ut-sally!ut-emx!jjr From: jjr@ut-emx.UUCP (Jeff Rodriguez) Newsgroups: comp.unix.questions Subject: Floating-Point Arithmetic in a Csh Script Message-ID: <1748@ut-emx.UUCP> Date: 17 Apr 88 15:22:26 GMT Reply-To: jjr@ut-emx.UUCP (Jeff Rodriguez) Organization: Dept. of Elec. Engr.; U. of TX at Austin Lines: 25 I am trying to do floating-point arithmetic in a csh script for 4.3 BSD. Since "@ x = 2.3 + 4.5" won't work, I'm using bc. But I can't find a nice way to get bc's output into a shell variable without using a temporary file. This method does not work: #!/bin/csh set x = `bc << END` scale = 5 $1 + $2 END This is the best that I've come up with: #!/bin/csh # This csh script computes x = $1 + $2, # where $1 and $2 are floating-point numbers. bc << END > temp scale = 5 $1 + $2 END set x = `cat temp` Can anybody think of a better way? Jeff Rodriguez jjr@emx.utexas.edu