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: Richard Stallman
Subject: Re: Using the GNU GMP Library for Bignums in Emacs
Date: Tue, 24 Apr 2018 21:05:55 -0400

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > In such applications, it's routine to have hexadecimal numbers that are 
wider 
  > than 32- or 64-bit words.

What is the motive for using hexadecimal in a case like that?

  > Even in the standard C library (which lacks bignums), the %x printf format 
is 
  > supposed to be used only with unsigned integers.

I think that's a misleading statement of what it does in C.  The rule
is to use it with an unsigned _type_.  The type, not the value, is
supposed to be unsigned.

In practice, what this means is that the hex output is done _treating
the number as unsigned_.  So -1, which is 0xffffffff as a 32-bit int,
will print as ffffffff, not as -1.

I contend that we want the same behavior in Emacs Lisp, too.

  > 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.

What conclusions we can draw from them, about Emacs Lisp, depends on
the number of bits in a non-bignum integer for each of them.  In
Emacs, 0xffffffff will be a bignum.  Is it a bignum in those other
systems?  If they can treat 32-bit ints as short, many programs that
want to use hex will never operate on a bignum.

-- 
Dr Richard Stallman
President, Free Software Foundation (https://gnu.org, https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
Skype: No way! See https://stallman.org/skype.html.




reply via email to

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