Skip to content

Add support for arbitrary large integers#74

Merged
smarr merged 13 commits intoSOM-st:masterfrom
smarr:big-int-support
Aug 16, 2025
Merged

Add support for arbitrary large integers#74
smarr merged 13 commits intoSOM-st:masterfrom
smarr:big-int-support

Conversation

@smarr
Copy link
Member

@smarr smarr commented Aug 16, 2025

This PR is finally adding support for integers of arbitrary precision, addressing #13.

It uses the fairly basic implementation by https://sercantutar.github.io/infint/
This is licensed under the Mozilla Public License, v. 2.0.

Introduce new macros:

  • SMALL_INT_VAL
  • IS_SMALL_INT
  • IS_BIG_INT
  • AS_BIG_INT
  • IS_DOUBLE
  • AS_DOUBLE

It also adds the VMBigInteger class. The InfInt.h implementation is slightly adapted for SOM++, but not optimized for performance.

This PR also does not ensure that values fitting into small ints are actually small ints.

smarr added 13 commits August 16, 2025 20:19
- fix the base for ParseInteger
- introduce SMALL_INT macros
- correctly negate literals when needed
- handle overflow for add, sub, multiply using compiler builtins

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Import version fc767eda13ce5981b768bdac44b3344344033bf3 of Mar 30, 2018.

This code is licensed under Mozilla Public License, v. 2.0.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
- it’s not yet standard, but the builtin seems to be available everywhere

Signed-off-by: Stefan Marr <git@stefan-marr.de>
Signed-off-by: Stefan Marr <git@stefan-marr.de>
@smarr smarr merged commit b54e07f into SOM-st:master Aug 16, 2025
52 of 55 checks passed
@smarr smarr deleted the big-int-support branch August 16, 2025 20:24
smarr added a commit that referenced this pull request Aug 17, 2025
…nto the small int range (#75)

This is the follow up to #74 and makes sure that we don't have
VMBigInteger objects that could just be tagged ints.

The PR also fixes a typing issue with the relevant macros and has a few
other minor improvements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant