Karim Belabas on Thu, 10 Dec 2015 15:22:02 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Regarding digits function |
* John Cremona [2015-12-10 11:26]: > On 10 December 2015 at 10:13, Bill Allombert > <Bill.Allombert@math.u-bordeaux.fr> wrote: > > On Thu, Dec 10, 2015 at 02:35:33PM +0530, chandra sekaran wrote: > >> Hi, > >> > >> digits(0) is giving empty vector. It should give [0]. > >> Am i correct or wrong? > > > > No, this is expected: this is consistent with binary(0). > > The idea is to remove all leading zeros. > > That is certainly the mathematically pure answer, but in Real Life we > strip leading 0s except for 0 itself, since we do not like empty > strings representing integers. Yes, our convention is that 0 has no digits. I just checked that both Maple (convert) and Mathematica (IntegerDigits) adopt another one; e.g. convert(0,base,2) yields [0]. > Perhaps the documentation could point this out? Done in 'master'. Cheers, K.B. -- Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 Universite de Bordeaux Fax: (+33) (0)5 40 00 69 50 351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/ F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP] `