-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Joel B. Mohler wrote:
|
| Since I was the last person to touch the digits method, I'll state my
case.
| Note that digits was (I think) inconsistent in this regard before my
| modifications -- I believe binary was different than other bases, but
I don't
| recall which way.
|
| I intentionally made 0.digits() return [] because that seems to me the
most
| consistent mathematical thing to do.  To make 0.digits() return [0] seems
| inconsistent to me because we don't pad any other number with 0's to the
| left.  I'm sure that one could imagine use cases where you would
really want
| either implementation for 0.digits().
|

I guess this is a question of convention, and depends on how you think
of "digit":

(1) a digit is a symbol used to construct representations of numbers,
and so the base 10 digits are: "0", "1", ..., "9".  In this case,
0.ndigits() should return 1 and 0.digits() should return [0]

(2) when writing an integer n in base b, you compute a b-adic expansion
        n = d_0 + d_1*b^1 + d_2*b^2 + ... + d_k b^k
with d_k nonzero; you call the d_i the "digits" of a.  Then 0 *has no
such expansion*, therefore 0.digits() should return [] and 0.ndigits()
should return 0.


I used to be very much in favor of option (1), but now that I actually
thought about it for 30 seconds, it doesn't really matter to me as long
as we document the chosen convention properly, and we are consistent.
Note that at the moment 0.digits() does (2) and 0.ndigits() does (1),
which is really bad.

Alex



- --
Alexandru Ghitza
Assistant Professor
Department of Mathematics
Colby College
Waterville, ME 04901
http://bayes.colby.edu/~ghitza/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH9Ou6dZTaNFFPILgRAlgJAJ4hBj/GR1NdxgkXxIXEtoeT12ry4gCgjgYq
3DDU6zKocIuQTlNHoiCL3s0=
=g8+f
-----END PGP SIGNATURE-----

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to