BASH question
Aaron Konstam
akonstam at sbcglobal.net
Sat Sep 9 23:20:40 UTC 2006
On Sat, 2006-09-09 at 23:54 +1000, Cameron Simpson wrote:
> On 09Sep2006 07:57, Aaron Konstam <akonstam at sbcglobal.net> wrote:
> | On Fri, 2006-09-08 at 16:38 -0500, Berna Massingill wrote:
> | > 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.
> | >
> | Ok, k works as shown above. But these fractional numbers are all
> | floating point.
>
> What makes you think they're floating point? As opposed to fixed point
> with 2 digits of precision after the point? Because they are fixed
> point, not floating point.
>
> I think you believe any number with a fractional part such as 1.5
> is floating point, but this is not so. That is just a number with a
> fractional part, no more. Floating versus fixed has to do with the
> internal representation of the value and how computatation is done with
> it, not whether it has a fractional part.
>
> Have a gander at this wikipedia article:
> http://en.wikipedia.org/wiki/Fixed-point_arithmetic
> It's not bad.
>
> Cheers,
> --
> Cameron Simpson <cs at zip.com.au> DoD#743
> http://www.cskk.ezoshosting.com/cs/
>
> There's no trick to being a humorist when you have the whole government
> working for you. - Will Rogers
> \
Look all this information is interesting. And indeed there have been
cpu-s that were capable of fixed point arithmetic. Pentiums are not
among them. I have not seen the source code for either bc or dc but I
doubt if they implement a form of fixed point arithmetic. It would be
possible to do this but it is an awful lot of trouble for something that
can be done in floating point arithmetic and then displayed with the
appropriate precision.
But if you know that bc and dc actually implement fixed point arithmetic
routines ans can testify to that fact I will be interested to hear about
it.
--
Aaron Konstam <akonstam at sbcglobal.net>
More information about the users
mailing list