[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: BASH question



On Fri, 2006-09-08 at 16:38 -0500, Berna Massingill wrote:
> On Fri, Sep 08, 2006 at 04:24:55PM -0500, Aaron Konstam wrote:
> 
> >>  On Fri, 2006-09-08 at 16:20 +0200, Sjoerd Mullender wrote:
> >>  > On 2006-09-08 16:01, Aaron Konstam wrote:
> >>  > > On Fri, 2006-09-08 at 15:35 +1000, Cameron Simpson wrote:
> >>  > >> On 07Sep2006 19:17, Khoa Ton <khoa puresynergy com> wrote:
> >>  > >> | >| I find dc (man dc) very useful for floating point arithmetic.
> >>  > >> | >I hate to tell you this, but dc does fixed point arithmetic, not
> >>  > >> | >floating point.
> >>  > >> | Thank you for the correction, Cameron.  I will use bc instead
> >>  > >> | of dc for floating point calculations from now on!
> >>  > >>
> >>  > >> 1: What's wrong with fixed point? For your purposes, I mean?
> >>  > >> 2: bc certainly used to be a wrapper for dc, so it was fixed point too!
> >>  > >>
> >>  > > 
> >>  > > I am confused about this discussion. If numbers with fractional parts are handled it
> >>  > > is doing floating point arithmetic. bc -l does floating point arithmetic. dc and bc 
> >>  > > work in such a different fashion it is hard to think one is a wrapper
> >>  > > for the other.
> >>  > > 
> >>  > 
> >>  > Fractional parts is not the same as floating point.  In fixed point
> >>  > arithmetic you have a fixed number of decimal places available, and in
> >>  > floating point, the point, well, floats.  But in either case you (can)
> >>  > have fractional parts.
> >>  > 
> >>  > And indeed, bc used to be (and perhaps still is?) a front end for dc.
> >>  > 
> >>  Well I am willing to learn but I am unaware that Pentium cpu-s have any way to represent numbers
> >>  with fractional parts other than floating point. So there is no such thing as fixed point representation of 
> >>  non-integer numbers on these machines.
> >>  
> >>  In addition I have not found any way to have dc deal with non-integers but that may be I am
> >>  missing something.
> >>  
> 
> I think you are:  The man page for dc talks about a "precision value"
> that controls the number of figures to the right of the decimal point.
> You set this value with the "k" command; e.g., "2 k" to set it to 2.
> 
> Compare the results of "1 2 / f" and "2 k 1 2 / f" for a quick example.
> 
> -- 
> -- blm
> 
Ok, k works as shown above. But these fractional numbers are all
floating point.
-- 
Aaron Konstam <akonstam sbcglobal net>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]