[Numpy-discussion] arange and floating point arguments
Sat Sep 15 00:12:34 CDT 2007
Robert Kern wrote:
> Here's the thing: binary floating point is intrinsically surprising to people
> who are only accustomed to decimal.
Very good point. Binary arithmetic is NOT less accurate that decimal
arithmetic, it just has different values that it can't represent
exactly. So one is surprised that 1.0/3.0 isn't represented exactly!
The confusion stems from th fact that we use decimal literals, even when
using binary arithmetic, but you just need to learn to get used to it.
For what it's worth, the MATLAB mailing list has a constant trickle of
notes from new users along the lines of "MATLAB is broken!" when they
have encountered binary-decimal issues like these. It is inescapable.
Binary representation was one of the first things I learned in my first
computer class , using Basic, over 25 years ago (am I really that old!).
You really need to learn at least a tiny bit about binary if you're
going to do math with computers.
Oh, and could someone post an actual example of a use for which FP
arange is required (with fudges to try to accommodate decimal to binary
conversion errors), and linspace won't do?
Christopher Barker, Ph.D.
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
More information about the Numpy-discussion