Skip to content

Conversation

@bettio
Copy link
Collaborator

@bettio bettio commented Oct 26, 2025

Add more bigint related functions to term.h, in order to avoid code duplication.
Also document existing ones, and use consistently the bigint word.

The codebase uses two related but distinct terms:

  • intn refers to the multi-precision integer implementation (the low-level arithmetic library that operates on arrays of digits)
  • bigint refers to the term type in AtomVM's type system (boxed integers larger than int64)

This separation allows the bigint term interface to remain stable even if the underlying multi-precision implementation changes. Functions in term.h use "bigint" because they work with terms, while intn.h contains the actual arithmetic implementation.

Continuation of #1930

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

@bettio bettio mentioned this pull request Oct 26, 2025
This function name is going to be used from term.h. Also since it is a
static helper, put verb first.

Signed-off-by: Davide Bettio <davide@uninstall.it>
Replace duplicated code with new functions in term.h.

Signed-off-by: Davide Bettio <davide@uninstall.it>
Use `term_initialize_bigint` instead of `term_intn_data` + `intn_copy`

Signed-off-by: Davide Bettio <davide@uninstall.it>
`term_create_uninitialized_intn` -> `term_create_uninitialized_bigint`
`term_intn_to_term_size` -> `term_bigint_size_requirements`

Also add doxygen documentation.

Signed-off-by: Davide Bettio <davide@uninstall.it>
Rename it to BOXED_BIGINT_HEAP_SIZE, and clarify that it must be always
used, in order to have the suitable size for allocating space for the bigint
term with its boxed header.

Signed-off-by: Davide Bettio <davide@uninstall.it>
@bettio bettio force-pushed the doc-and-improve-bigint-term-funcs branch from c06ba96 to 10ce113 Compare October 28, 2025 10:53
@bettio bettio changed the base branch from feature/bigint to main October 28, 2025 10:53
@bettio bettio changed the base branch from main to feature/bigint October 28, 2025 10:53
Copy link
Collaborator

@pguyot pguyot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally convinced by term_to_bigint and conv_term_to_bigint function names, but I'll get used to it. conv_term_to_bigint is not meant to be used, but term_to_bigint can be a little bit misleading. But the documentation is clear.

@bettio bettio merged commit 014c48b into atomvm:feature/bigint Oct 28, 2025
146 of 147 checks passed
bettio added a commit that referenced this pull request Oct 29, 2025
bif.c bigint cleanup

Move functions & rename variables (to understandable names).

Continuation of #1933

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
bettio added a commit that referenced this pull request Oct 31, 2025
Fix static_assert in header

Continuation of #1933

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
bettio added a commit that referenced this pull request Nov 1, 2025
Minimal bigint pattern matching

Add everything needed to allow JIT compiler (with big integers support) to run on AtomVM.

Continuation of #1933

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants