Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement \bigint_eval:n based on the internals of \fp_eval:n #251

Closed
blefloch opened this issue Aug 11, 2015 · 4 comments
Closed

Implement \bigint_eval:n based on the internals of \fp_eval:n #251

blefloch opened this issue Aug 11, 2015 · 4 comments
Assignees
Labels
enhancement New feature or request l3trial Issues with unreleased code

Comments

@blefloch
Copy link
Member

Every once in a while a user asks for the ability to manipulate integers beyond the 32-bit range handled by TeX. This is solved for instance by bigintcalc and more recently by xint (manipulating big integer expressions). It may be good to have an implementation in expl3. Use cases:

  • siunitx, where Joseph needs to be able to round etc. (I've asked him for details)
  • hyperref to manipulate bit sets used in pdf forms (in fact these bit sets seem to be short enough to fit in normal integers... I've asked Heiko)
  • users wanting to compute factorials, Fibonacci numbers, Mersenne primes, ...

Unless I'm mistaken, there will be no ned for fast multiplication, and even addition may be done rather slowly. Optimization will have a very low priority and I will focus on keeping the code concise and clear (just the opposite of l3fp).

@blefloch
Copy link
Member Author

The plan is to support the same syntax as integer expressions: ()+-*/, automatically unpacking registers, and probably at some point " (hex), ' (octal), ` (charcode).

@blefloch blefloch self-assigned this Aug 11, 2015
@blefloch
Copy link
Member Author

I've started, and got addition/subtraction mostly working (reasonably fast, up to the limit of TeX's input levels, so 19900 digits or so). Other uses have come up in discussions.

  • computing md5 or other hashes requires doing computations on 32-bit words (or other-sized words).
  • perhaps for decoding base64 encoding and some such, or for working with binary files (extract data from images/\pdffiledump)
  • converting from binary floating point formats to decimal ones (e.g. some plan I have to "un-\dump" a compiled Lua file in order to run some Lua code from pdfTeX/XeTeX without having to write a full Lua interpreter)

@josephwright
Copy link
Member

I've worked out now that siunitx can live without this (it's only about comparisons of arbitrary numbers for rounding, and I've implemented a different way). I've also had a quick look over the hyperref code and I'm reasonably confident that the actual range needed for PDF flags is fine with the standard int functions. So it's only the esoteric number theory stuff that would require big integers. Those can already be covered by e.g. xint: not sure we really need to worry further (at least not at the moment).

@josephwright josephwright added enhancement New feature or request l3trial Issues with unreleased code labels Sep 30, 2018
@josephwright
Copy link
Member

I think at this stage we are unlikely to do this: the real use cases simply don't exist at the level we'd want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request l3trial Issues with unreleased code
Projects
None yet
Development

No branches or pull requests

2 participants