Results 1 to 4 of 4
Alright i have to use bc to do some floating point calculations. I was told in order to do floating point calculations with bc the -l option has to be ...
- 04-10-2007 #1Just Joined!
- Join Date
- Sep 2005
- Posts
- 99
using bc
Alright i have to use bc to do some floating point calculations. I was told in order to do floating point calculations with bc the -l option has to be used. However, i use the command
This is all floating point arithmetic and it seems to work fine without the -l option on bc. Anyone know if this is ok or if the -l option is needed or why there is this debate about the -l option for bc and floating point calculations?Code:xScale=$(echo "scale=5 ; ($maxX - $minX)/80" | bc)
- 04-11-2007 #2
- 04-11-2007 #3Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
The bc calculation tool is very useful in situations like this.
What does your man page say about option -l? ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 04-11-2007 #4Just Joined!
- Join Date
- Sep 2005
- Posts
- 99
-l does this "Defines the math functions and initializes
scale to 20, instead of the default zero." But in my calculations i have the scale set to 5 and i think thats good enough. Does that mean that bc doesnt "work" with floating point because just using bc truncates the decimal but by using -l it would set the scale to 20 therefore it wont truncate the result? I have my scale to 5 and it truncates the result after 5 decimal places which i think is a good enough estimate.


Reply With Quote