Skript

Skript

743k Downloads

Numbers maxing out at Long instead of Double when using ^

EwansXD opened this issue ยท 5 comments

commented

Skript/Server Version

[18:06:28 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[18:06:28 INFO]: [Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[18:06:28 INFO]: [Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[18:06:28 INFO]: [Skript] Server Version: git-Paper-"f4c7d37" (MC: 1.20.4)
[18:06:28 INFO]: [Skript] Skript Version: 2.9.2 (skriptlang-github)
[18:06:28 INFO]: [Skript] Installed Skript Addons: 
[18:06:28 INFO]: [Skript]  - skript-placeholders v1.5.2 (https://github.com/APickledWalrus/skript-placeholders)
[18:06:28 INFO]: [Skript]  - skript-gui v1.3 (https://github.com/APickledWalrus/skript-gui)
[18:06:28 INFO]: [Skript]  - skript-reflect v2.4 (https://github.com/SkriptLang/skript-reflect)
[18:06:28 INFO]: [Skript]  - SkQuery v4.1.10
[18:06:28 INFO]: [Skript]  - SkBee v3.6.1 (https://github.com/ShaneBeee/SkBee)
[18:06:28 INFO]: [Skript] Installed dependencies: 
[18:06:28 INFO]: [Skript]  - Vault v1.7.3-b131
[18:06:28 INFO]: [Skript]  - WorldGuard v7.0.9+5934e49

Bug Description

When attempting to use ^ the number maxes out at the max Long which is causing my formatting function to break for numbers ecceeding 9,223,372,036,854,775,807 resulting in output such as:
image

Expected Behavior

the output should be 1s, not 108.42s

Steps to Reproduce

on load:
    set {-number-suffixes::*} to split "k,M,B,T,q,Q,s,S,o,n,d" at ","

function nFormat(n: number) :: string:
  set {_div} to floor(log(max(abs({_n}), 1), 1000))
  return "%{_n} / (1000 ^ {_div})%%{-number-suffixes::%{_div}%} ? ""%"
  
command /test:
  trigger:
    broadcast nFormat(player's balance)
    broadcast player's balance

To make this work, you will have to increase the max balance in essentials config or whatever economy plugin being used.

Errors or Screenshots

No response

Other

No response

Agreement

  • I have read the guidelines above and affirm I am following them with this report.
commented

Updated it about 5 minutes ago, this issue does still occur.

commented

Unrelated

Does this still occur when using 2.5.1 skript-reflect? Skript-reflect 2.4 is not compatible with Skript 2.9+

commented

Does this still occur when using 2.5.1 skript-reflect? Skript-reflect 2.4 is not compatible with Skript 2.9+

commented

Sovde has a fix for this, but you've reached the computational limit of what can be expressed in signed 64-bit integers, so you're going to have problems doing anything that requires a whole number.

You'll be able to exceed this limit using decimals but it's not going to be accurate (floating point numbers are accurate up to roughly ~14 or 15 significant figures) so with the kinds of numbers you want to add up, you could potentially accumulate errors within the thousands across a few sums.

If you're just using really big numbers because it sounds cool, I suppose you could actually store a smaller number and just pretend it's larger when displaying it.

Alternatively, if you do need to keep an accurate count, maybe store two separate values (e.g. one variable representing billions, another representing the remainder)

commented

I see your concern however in my case its going to be used to display the highest 3-4 figures for example 10.1T, the entire number will not be visible player-side unless their balance is low enough for it to be seen (in turn not requiring the formatter)so its not too much to be worried about as of now but I will take your suggestion into consideration if we in fact decide to go higher, thankyou (=