Skip to content

Conversation

@bettio
Copy link
Collaborator

@bettio bettio commented Dec 14, 2025

Add functions useful to deal with int32_t,uint32_t,int64_t and uint64_t to term.h.

These functions are useful to safely convert terms to C stdint types, regardless of the term representation that can be either small, boxed or big integers.

This PR is based on #1880 that has been closed by mistake.

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 force-pushed the term-uint32-64-functions branch 4 times, most recently from 02fdb6d to 18ab8d3 Compare December 15, 2025 13:58
Add functions that are specific to int32 and int64 and less error prone.
These functions have been introduced after big integers introduction in
order to avoid bugs (since previous functions were more error prone).

Signed-off-by: Davide Bettio <davide@uninstall.it>
Add a function for converting the uint64_t special case.
Support for int32_t and int64_t was already there, but also uint64_t can
be reppresented using 2 digits.
The newly introduce predicate also counts digits so input doesn't have
to be normalized.

Signed-off-by: Davide Bettio <davide@uninstall.it>
uint32_t and uint64_t are widely common when dealing with low level
features such as peripherals. So, add new functions to avoid possible
bugs with quite common usages.

Signed-off-by: Davide Bettio <davide@uninstall.it>
@bettio bettio force-pushed the term-uint32-64-functions branch from 18ab8d3 to 002a4d1 Compare December 23, 2025 14:16
@bettio bettio merged commit b743490 into atomvm:main Dec 25, 2025
207 of 210 checks passed
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.

1 participant