how to compare big real numbers

Hi everyone,

I need to compare 2 big Floating/Real numbers in a script.

After the comparission it is showing worng values in my script.

echo "Enter value1"
read value1
echo "Enter value2"
read value2

Result=`echo "if($value1 > $value2) 1" | bc`

if [ $Result -eq 1 ]; then
echo "$value1 is greater"
fi

Please correct this code ..

Hi everyone,

I need to compare 2 big Floating/Real numbers in a script.

After the comparission it is showing worng values in my script.

echo "Enter value1"
read value1
echo "Enter value2"
read value2

Result=`echo "if($value1 > $value2) 1" | bc`

if [ $Result -eq 1 ]; then
echo "$value1 is greater"
fi

Please correct this code ..

The script seems correct, but you may substitute "bc" with "bc -l".

try echo $Result to see what it actually contains.

What shell are you using? Not all shells support floating
point number comparison.

If you are using ksh you may need to do something like

echo "Enter value1"
typeset -F value1
read value1