On Dec 29, 2019, at 13:33, Chris Angelico <ros...@gmail.com> wrote: > > More useful would be to look at the useful operations and invariants > that can be maintained, but that doesn't work too well for finite > subsets of numbers. Very few operations are closed for, say, "sixteen > bit integers". Nor for "rational numbers with denominators that are > powers of two between -1024 and 1024". There is no easy way to define > "number" in a way that is both mathematically pure AND practically > useful.
There are a whole lot of operations that are closed over 16-bit integers or IEEE doubles. Every possible total function from uint16 x uint16 -> uint16 or binary64 x binary64 -> binary64 is a closed operation, and every pair of such functions defines a valid magma-over-magma structure. The problem isn’t that there aren’t enough such operations, it’s that none of them meet the usual “number” axioms without being trivial in some important way. In particular, IEEE addition isn’t associative, invertible, etc., so IEEE binary64 isn’t even a semiring, much less a field, it’s just a magma-over-magma. But it is, out of all of the possible magma-over-magma structures on those values, the one that most closely approximates—in a well-defined and useful, if very complicated, way—the rationals. That’s not a structure you’d ever study mathematically for its own sake, but it’s a structure you can study mathematically if it’s useful—as it is for the sake of making sense of computer programs. (In the case of uint16, that actually does form a useful structure on its own if you consider them as Z/65536Z, but maybe it’s still worth considering them as an approximation of N instead.) _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/N75BS7L2LRILC522MKJTBEBYGI7GQVIG/ Code of Conduct: http://python.org/psf/codeofconduct/