LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   not getting floating answer when divident is smaller than divider (https://www.linuxquestions.org/questions/linux-general-1/not-getting-floating-answer-when-divident-is-smaller-than-divider-4175433951/)

alavala53 10-24-2012 09:23 PM

not getting floating answer when divident is smaller than divider
 
not getting floating answer when divident is smaller than divider.getting 0 for all values
problem:
a=2 b=4
c=`echo $a / $b |bc`
echo $c

ans:
0

please help me in this issue

Basher52 10-24-2012 09:29 PM

Try this


Quote:

`echo "scale=2;2/3" |bc`
where scale=2 gives you 2 decimals

Quote:

a=2 b=4
c=`echo "scale=2;" $a / $b |bc`
echo $c


All times are GMT -5. The time now is 09:46 PM.