Vasili Burdo on Thu, 16 Jul 2015 00:53:58 +0200


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

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


>Even so, this is still worthwhile to do.
Ok. Will deliver tomorrow.

>I assume your patch was created to apply to PARI 2.7.4 ?
No, it's for master - i.e. trunk.
I'm new to git - work mostly w/ perforce and svn

>Your patch changes the result of strtoi
Hm, could you point me to the test which fails?

>? strtoi("0b111")
>%1 = 7
>instead of 0.
Hm, silent failure in basecase and something useful w/ my changes.
Looks like my change is better :)

But anyways, provided I have existing test case at hands I'll try to mitigate it.

>Currently, GP printf can print in hexadecimal and octal but not in binary.

But, my change goes beyond this.
If default base is changed to hex, ALL integer values are printed in hex.
I.e. Mod(20,33) will look like Mod(0x14,0x21)
To me, it's really useful when I use GP as a fancy programmer's calculator.
I play with bignum arithmetic in my spare time. And for debugging I often do calculations in GP.
I use custom functions to convert between dec and hex and it's always a pain.
Getting all results in desired base is much better.
That's why I propose this patch.