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

Incorrect integer returned #2

Open
ArikRahman opened this issue Jan 14, 2023 · 3 comments
Open

Incorrect integer returned #2

ArikRahman opened this issue Jan 14, 2023 · 3 comments

Comments

@ArikRahman
Copy link

playground.zip
The attached file demonstrates this chunk of code:
var a: Int128
a = i128("1231231298371293217931712312312983712932179317")
echo(a)

Returns this number:
30447654189836100383415788052960652661

Here were the release flags used:
nimble build --mm:orc --threads:on -r -d:release

It appears there is a discrepancy.

@ArikRahman
Copy link
Author

In addition, this code:

a = i128("270141183460469231731687303715884105727")

echo(a)

Results in:
99999999999999999999999999999999999999

@ArikRahman
Copy link
Author

This code:
a = i128("170141183460469231731687303715884105730")
Results in 2.

However,
a = i128("170141183460469231731687303715884105729")
and
a = i128("170141183460469231731687303715884105728")

Are overflow. Is this intentional?

@rockcavera
Copy link
Owner

Thank you for the report.

The current behavior is intentional, as overflow detection is not implemented. It's something I've been studying how to implement in the best possible way.

The current code is as if it were always compiling with -d:danger.

So any number above high(Int128) == 170141183460469231731687303715884105727 you can expect this silent overflow behavior.

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

No branches or pull requests

2 participants