Floating-Point Arithmetic in a Csh Script
Rick Lindsley
richl at penguin.USS.TEK.COM
Tue Apr 26 07:39:57 AEST 1988
In article <1748 at ut-emx.UUCP> jjr at ut-emx.UUCP (Jeff Rodriguez) writes:
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?
How about:
set x = `echo "scale=5; $1 + $2" | bc`
Same effect, less space.
Rick
More information about the Comp.unix.questions
mailing list