We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
1)From shell just enter 'bc' then type 1/3 and press enter you will get output 0 and exit.
$ bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
1/3<============================
0<<<<<<<<<<<<<<<<<<<<<<<<<<<
Now try command "bc -l" and repeat the same as in step 1.
2)$ bc -l
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
1/3<======================================
.33333333333333333333<<<<<<<<<<<<<<<<<<<<<<
Now comparing outputs from above two scenerios you can see that without using -l option 1/3 returns 0 without the fraction parts.
You can also try commands like below which will help to understand
echo "15/7" | bc -l
2.14285714285714285714
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Compute the Average
You are viewing a single comment's thread. Return to all comments →
Try below two commands and observe the output.
1)From shell just enter 'bc' then type 1/3 and press enter you will get output 0 and exit.
$ bc bc 1.06.95 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. 1/3<============================ 0<<<<<<<<<<<<<<<<<<<<<<<<<<<
Now try command "bc -l" and repeat the same as in step 1.
2)$ bc -l bc 1.06.95 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. 1/3<====================================== .33333333333333333333<<<<<<<<<<<<<<<<<<<<<<
Now comparing outputs from above two scenerios you can see that without using -l option 1/3 returns 0 without the fraction parts.
You can also try commands like below which will help to understand
echo "15/7" | bc -l 2.14285714285714285714