Which is the best way/command to do mathematics in UNIX scripting?

Hello all!
I used to use expr for doing simple mathematics, but has a main advantage and a main disadvantage:
The advantage is that it can take variables for numbers

(e.g.{1}: echo "Give me first"
read lol
echo "Give other"
read lil
sum=`expr $lol + $lil`
echo "The sum of $lol and $lil = $sum")

The disadvantage is that it cannot give float numbers.It gives errors (example for 2 / 5 .......)
Somebody told me about bc but I cannot give him variables.The program I wanna make is similar to example {1} but I need float numbers!
if the program is like this:

read lol
read lil
echo "scale=2; $lol - $lil" | bc

bc gives error.The only way to avoid this error is this way:

lol=5 ; lil=2 ; echo "scale=2; $lol - $lil" | bc

But in this way you don't allow the user to choose himself the variables.
Somebody told me that

read lol
read lil
echo "scale=2; $lol - $lil" | bc

works, but unfortunately in my OS doesn't work(Ubuntu 9.10)
Any suggestions/ideas????

Follow this url ,

Floating Point Math in Bash | Linux Journal

This thread might help you

Use "bc -l" for floating point result, but for actually retaining proper scale you would need to use printf.

A hunch. How did you execute these three lines?

If you type them one-by-one at the command prompt answering each "read" before typing the next command ... they should work.

If you put them in a shell script and execute the script ... they should work.

If you cut/paste all three lines onto the command line they will fail. This is because the second line becomes the input to the first line meaning that $lol contains the string "read lil" which in turn makes the echo contain rubbish to pass to "bc".

Thx for your replies.