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

Variable numbers not going over 9.223 Quintillion (IDK if bug or something else) #7209

Open
1 task done
somofnut opened this issue Nov 10, 2024 · 6 comments
Open
1 task done
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. PR available Issues which have a yet-to-be merged PR resolving it

Comments

@somofnut
Copy link

Skript/Server Version

[Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[Skript] Server Version: git-Paper-496 (MC: 1.20.4)
[Skript] Skript Version: 2.9.3 (skriptlang-github)
[Skript] Installed Skript Addons: 
[Skript]  - skDragon v0.17-alex-MC1.18-hack-4
[Skript]  - SkQuery v4.1.10
[Skript]  - SkBee v3.4.0 (https://github.com/ShaneBeee/SkBee)
[Skript]  - FunkySk v1.0.2
[Skript] Installed dependencies: 
[Skript]  - Vault v1.7.3-b131
[Skript]  - WorldGuard v7.0.9+5934e49

Bug Description

I’ve created a superpower training simulator server on my PC, using the Feather client on Minecraft 1.20.4. However, I’ve run into an issue with stat gains. Whenever any of the stats reach the 64-bit integer limit (around 9.223 quintillion), the number turns negative and won’t increase beyond that limit.

I’m running Windows 11, and I believe it’s a 64-bit version (though I’m not sure of the specific edition). I’m wondering if the issue is related to this, because I haven’t seen others reporting the same problem. This bug only occurs when using later versions of Skript, Like the 2.8 and 2.9 versions. In earlier versions (2.6.x or 2.7.x), I was able to reach numbers as large as 1.79e308, which leads me to believe that something changed in Skript that limits numbers to the maximum value allowed by my PC’s architecture (the 64-bit limit).

Expected Behavior

Previously, in Skript versions 2.6.x or 2.7.x, variables could reach numbers as large as 1.79e308 (the limit of a double-precision floating-point number). However, in the current version, numbers using variables should continue to increment beyond the 64-bit integer limit, without turning negative or being restricted to the 64-bit integer range. The expectation is that the system should handle large numbers properly, similar to how it worked in the earlier Skript versions, where values could exceed the 64-bit integer limit and reach extremely large numbers. As mentioned in the bug description section.

Steps to Reproduce

Really no code is required to be shown as it is with every single variable i use. I can try to send a screenshot.
If screenshot doesnt work, i can explain whats on the picture as steps to reproduce are just to add a huge number to another huge number to achieve the -9.223 Qi stuff. The screenshot shows red text saying "+-9.22Qi Strength".

Errors or Screenshots

image

Other

I hope i explained everything as much as i could, as this is my first time writing a report for skript.

Agreement

  • I have read the guidelines above and affirm I am following them with this report.
@somofnut somofnut changed the title Variable numbers not going over 9.223 Quintillion (IDK if bug or something) Variable numbers not going over 9.223 Quintillion (IDK if bug or something else) Nov 10, 2024
@Fusezion
Copy link
Contributor

Update skript to 2.9.4, the %number% ^ %number% use to cap at Long.MAX_VALUE

@somofnut
Copy link
Author

does that mean if i update to skript 2.9.4 i can use numbers above 9.223 Qi?

@somofnut
Copy link
Author

I have updated the plugin to 2.9.4 but the bug still occurs. I think im just gonna downgrade to the version which worked perfectly fine with numbers above 9.223 qi until they do something about it

@erenkarakal
Copy link
Member

erenkarakal commented Nov 10, 2024

The issue is that your strength value is a Long (capped at 9,223,372,036,854,775,807) while the other value you are talking about is the max value for a Double. Adding a decimal to the number seems to be fixing the issue. The image below is from Skript 2.9.4 but I don't think version will matter
image

Also keep in mind that you will lose precision when you do this. If you want precision you should use the BigInteger class with skript-reflect

@Efnilite Efnilite closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2024
@sovdeeth
Copy link
Member

sovdeeth commented Nov 10, 2024

Sorry folks this is actually a bug and should be fixed! It's due to Skript's number arithmetic not handling integer overflows. It should naturally switch to a double if a long isn't big enough, but it doesn't do those checks.
image

@sovdeeth sovdeeth reopened this Nov 10, 2024
@sovdeeth sovdeeth added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Nov 10, 2024
@somofnut
Copy link
Author

Thanks for noticing my bug report as i have not really seen anyone else report this exact bug so im happy to know that i may be able to use newer skript versions for my SPTS game, instead of 2.7.3.

@sovdeeth sovdeeth added the PR available Issues which have a yet-to-be merged PR resolving it label Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. PR available Issues which have a yet-to-be merged PR resolving it
Projects
None yet
Development

No branches or pull requests

5 participants