IEEE 754
John W. Baxter
jwbnews at scandaroon.com
Mon Jul 24 20:37:18 EDT 2000
In article <8liiba$1mh$1 at agate.berkeley.edu>, ejr at lotus.CS.Berkeley.EDU
(Edward Jason Riedy) wrote:
> And John W. Baxter writes:
> -
> - You mean I may someday be able to put aside my answers to the "why
> - doesn't 2/10 print as 0.2 as we all know it should?" sorts of
> questions?
>
> I wish. IEEE 854 is a radix-independent FP standard. It could be
> implemented for base-10 in hardware, but only some hand calculators
> have done that. There are many libraries for BCD-style arithmetic,
> but I don't know how good or fast they are. I don't understand all
> the issues involved.
>
> Way off-topic: Besides, not all numbers are natural for base-10.
> One example is pi. It strongly appears that the only natural base
> for pi is 16 (pi may be base-16 normal and not base-10 normal). Not
> proven yet, but looking likely. See
> http://www.nersc.gov/~dhbailey/dhbpapers/bcrandom.ps for some neat
> pi results.
>
> Back on topic: Python's answer is even more painful to explain:
> > bash-2.03$ python -c 'print 2/10'
> > 0
>
> Jason
I have no problem with 2/10 being zero. If one does integer arithmetic,
one gets integer arithmetic results.
People who initially learned C with its silly standard conversions and
different operator definitions have other biases...but I've been around
computers nearly twice as long as C has (as of sometime around 1994 I
had to stop saying "more than twice as long").
--John
--
John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com
More information about the Python-list
mailing list