Bill Allombert on Thu, 16 Jul 2015 00:17:19 +0200


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

Re: Support of binary and hexadecimal integers in PARI/GP


On Wed, Jul 15, 2015 at 09:48:28PM +0300, Vasili Burdo wrote:
> Hi, Bill
> 
> Do you mean one patch for parsing '0x' and '0b'
> and another for printing hex, setting options, etc?

Yes.

> Then, there is no need to create 2 separate patches.
> Because changes in src/language/anal.c apply for parsing only.
 
> All other changes apply for everything else.

Even so, this is still worthwhile to do.

I assume your patch was created to apply to PARI 2.7.4 ?

Your patch changes the result of strtoi:
? install("strtoi",s)
  *** install: Warning: [install] updating 'strtoi' prototype; module not reloaded.
? strtoi("0b111")
%1 = 7
instead of 0.

Currently, GP printf can print in hexadecimal and octal but not in binary:
? printf("0x%x",3^32)
0x6954fe21e3e81
? printf("%o",3^32)
64524774207437201

Cheers,
Bill.