emacs-devel
[Top][All Lists]
Advanced

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

Re: Using the GNU GMP Library for Bignums in Emacs


From: Paul Eggert
Subject: Re: Using the GNU GMP Library for Bignums in Emacs
Date: Mon, 23 Apr 2018 21:35:31 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

Richard Stallman wrote:
In practice, I think, the cases where one wants hexadecimal
are cases where there is a word width.

Although that is true in traditional usage where word width is assumed, it's not true for most applications using bignums, the original context of this thread. In such applications, it's routine to have hexadecimal numbers that are wider than 32- or 64-bit words. And these numbers (when printed without a sign) are routinely treated as nonnegative, not as negative. For an example of this sort of application, see the OpenSSL C code that deals with bignums: e.g., BN_bn2hex generates a leading "-" when converting a negative number to a hexadecimal string.

Even in the standard C library (which lacks bignums), the %x printf format is supposed to be used only with unsigned integers. Nowadays GCC even optionally warns about using %x on signed integers.

The reason to invent a special syntax is to get the commonly desired
result in a simpler way.

If it turns out to be useful to have a shorthand printf format for formatting the least N bits of an argument, we can add it as needed. I have my doubts, though, as other bignum formatters seem to get along fine without such a feature.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]