Ilya Zakharevich on Thu, 11 Jul 2024 09:43:10 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Major problems with bitprecision()


On Thu, Jul 11, 2024 at 12:36:49AM -0700, Ilya Zakharevich wrote:
>   (00:24) gp > my(d=(1.-1.)*2^bitprecision(1.)); d
>   %4039 = 0.E1
>   (00:07) gp > my(d=(1.-1.)*2^bitprecision(1.)); d==1
>   %4027 = 1
>   (00:22) gp > my(d=(1.-1.)*2^bitprecision(1.)); d<1
>   %4037 = 0
>   (00:23) gp > my(d=(1.-1.)*2^bitprecision(1.)); exponent(d)-bitprecision(d)
>   %4038 = -63
>   (00:27) gp > my(d=(1.-1.)*2^bitprecision(1.)); exponent(d)
>   %4044 = 1
>   (00:29) gp > my(d=(1.-1.)*2^bitprecision(1.)); d<2
>   %4045 = 0
>   (00:33) gp > my(d=(1.-1.)*2^bitprecision(1.)); d<4
>   %4046 = 1
>   (00:33) gp > my(d=(1.-1.)*2^bitprecision(1.)); d==3
>   %4047 = 1

The actual bug (whereever: in PARI, or in my code) I can see is that

  (00:33) gp > my(d=(1.-1.)*2^bitprecision(1.)); max(d,3)
  %4048 = 0.E1
  (00:38) gp > my(d=(1.-1.)*2^bitprecision(1.)); max(d,3) > 2
  %4049 = 0

This completely breaks all the logic…

Thanks,
Ilya