Tuesday, May 7, 2024
123
rated 0 times [  123] [ 0]  / answers: 1 / hits: 131735  / 2 Years ago, wed, march 2, 2022, 1:04:38

bc handles numbers as integers:



# echo "100/3" | bc
33


bc -l handles numbers as floating point objects:



# echo "100/3" | bc -l
33.33333333333333333333


Is there a way to limit the number of digits after the decimal point?


More From » command-line

 Answers
5

Set the scale special variable:



$ echo "scale=2; 100/3" | bc
33.33

[#34275] Wednesday, March 2, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
azaaburge

Total Points: 266
Total Questions: 85
Total Answers: 109

Location: Djibouti
Member since Sat, Oct 29, 2022
2 Years ago
;