On 08Sep2006 16:24, Aaron Konstam <akonstam@xxxxxxxxxxxxx> wrote: | On Fri, 2006-09-08 at 16:20 +0200, Sjoerd Mullender wrote: | > 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. Not so. Pentiums do not, _internally_, have anything but integers and floating point registers. However, a program can by manipulation do fixed point arithmetic. It just has to construct it. Consider: dc does arithmetic on numbers of arbitrary size - that is one of its benefits. Yet the Pention only has 32 and 64 bit registers. Shall we say you can't run dc? No; the program just has a data format to represent arbitrary size integers, and it manipulated that. Fixed point just means you have a fixed amount of precision beyond the decimal point. (Well, fraction point if a base other than 10). Floating point means fixed accuracy and a sliding scale factor i.e. a fixed number of mantissa bits and an exponent component. It's like scientific notation with a fixed number of digits for the front part (and a limit on the exponent too). So, a fixed point value will always have the same precision but a limit scale. If it had two decimal places after the point it could not represent values more finely than to the nearest .01. If we had 10 digits of storage for the number we could represent all values from 0.00 to 99999999.99 with precision of 0.01. A floating point value sacrifices some storage for an exponent. This lets it move the scale. Pretending base 10, and presuming we use 2 digits for the exponent the the float might represent values from 0.0000000 * 10^00 through to 9.9999999 * 10^99. You can see that its range is MUCH larger, but its accuracy is smaller (8 digits of accuracy, not 10). This is generally more useful in the real world. However, note that financial values generally want to be fixed point unless you want fractional pennies/cents or round off. dc is an integer computation program with arbitrary precision. It will, subject to enough comouter memory, compute on values of any size. bc is a wrapper that does fractional arithmetic using those integers and a scale factor, so it is fixed point. But because dc does arbitrary sized integers, bc may do arbitrary sized fixed point. It can happily talk about: 123646575756537468756756583872.5987658756876 Normal floating point is not that good - they want to store values in 32 bits (single precision) or 64 (double precision). | In addition I have not found any way to have dc deal with non-integers | but that may be I am missing something. bc and awk and perl and python and C and ... all handle non-integers. Except for bc, the others use floating point, and probably use the machine's native CPU floating point operations. Cheers, -- Cameron Simpson <cs@xxxxxxxxxx> DoD#743 http://www.cskk.ezoshosting.com/cs/ The road less traveled is FASTER !! - Luc Marcouiller, marcouil@xxxxxxxxxxxxxxxx