#!/bin/csh
# check numerical error versus a threshold.
# arguments:
# val1
# val2
# threshold
# the number of significant digits in printing the difference
#
#@ n = $4 + 4
#set diff=`echo $1 $2 $n $4 |awk '{ printf "%*.*f",$3,$4,($1>$2?$1-$2:$2-$1) }'`
#
#    the next three lines do not work on Solaris
#set diff=`echo $1 $2 | awk '{ printf "%.1e",($1>$2?$1-$2:$2-$1) }'`
#echo $diff
#exit `echo $diff $3 | awk '{ print ($1>$2) }'`
#
set diff=`echo $1 $2 | awk '{ if($1>$2) printf "%.1e",$1-$2 ; else printf "%.1e",$2-$1 }'`
echo $diff
exit `echo $diff $3 | awk '{ if($1>$2) print 1 ; else print 0 }'`
