Karim Belabas on Thu, 28 Oct 2021 02:04:05 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: sqrtint() on non-integer arguments |
* Kevin Ryde [2021-10-28 00:46]: > Karim Belabas <Karim.Belabas@math.u-bordeaux.fr> writes: > > > > get instead > > ? sqrtint(1e40) > > %1 = 100000000000000000000 > > Could keep that as precision loss error, since low bits of the root are > essentially unknown, within selected float precision. I have to assume that the input is correct as given otherwise the original request is meaningless anyway: even floor(1.0) would not be well defined if 1.0 may represent any real number within 1ulp (the floor could be 0 or 1). And the largest integer x such that x^2 <= 1e40 is indeed 10^20. I chose to compute sqrtint(y) as floor(sqrt(y)) or sqrtint(floor(y)) if either is defined [if both are defined, they are equal; and the first expression is always defined when the ѕecond is] 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 21 23 351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/ F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP] `