Pages

lundi 16 janvier 2012

compare float number in csh

the shell deals with the integer numbers, not with float numbers. Eg., expr 1 + 2 can produces 3, but it does not work with float.

In order to deal with float numbers, we can use either bc, or awk.

For example,
set a = 0.1
if (`echo "$a > 0" | /usr/bin/bc `) then
echo OK
endif

Aucun commentaire:

Enregistrer un commentaire