Having skript remove a percentage of a number results in skript removing the decimal version instead of the percentage of the original number.
command /percent <number>:
usage: /percent (number)
trigger:
set {_skmath} to arg 1-1%
message "Skript Math: %{_skmath}%"
set {_math} to 0.01*arg 1
set {_math} to arg 1-{_math}
message "Manual math: %{_math}%"
For example set {_math} to 100-1% results in 99.99 because it translates 1% to 0.01 instead of 1% of 100 before removing the amount.
Minecraft: 1.14.4
Paper: 234
Spigot: git-Spigot-56f8471-3e3818b (MC: 1.14.4)
Skript: 2.4 Stable
I don't think this is intended, so I'm sorry if it is. This is quite confusing, and I didn't see another way to take a percentage value of a number within Skript (for example set {_math} to 1% of 100).
I'm not too sure what you mean here, 1% is 0.01, and Skript is not wrong in that respect.
I'm not too sure what you mean here, 1% is 0.01, and Skript is not wrong in that respect.
Yes but 1% of 100 is 1. Skript hasn't always translated 1% into decimals like it is now. It's rather confusing and honestly pretty useless.
To clarify a little more set {_math} to 100-1% results in 99.99 because it translates 1% to 0.01 instead of 1% of 100. I don't believe this has always worked this way, but I don't recall many times of needing a percentage.
@ThePumpkin5822 Not sure how you think percentages are calculated, but you surely don't do it by removing 1% from the value. Skript is right here. To get 99 from this, do 100 - (100 * 1%)
@ThePumpkin5822 Not sure how you think percentages are calculated, but you surely don't do it by removing 1% from the value. Skript is right here. To get 99 from this, do
100 - (100 * 1%)
That is utterly useless and confusing for new users. I can do the exact same thing with 0.01.
set {_math} to {var}-(0.01*{var})
@ThePumpkin5822 Please refer to this image
@ThePumpkin5822 Please refer to this image
You're saying math is useless? Brilliant. @bensku What are your thoughts on this?
@ThePumpkin5822 Please refer to this image
You're saying math is useless? Brilliant. @bensku What are your thoughts on this?
Where did you get that? Also, according to calculators (but, as far as I can see, no official documentation), this issue is valid, and 100-1% is 99, not 99.99. Skript would probably need to implement special handling for this — this seems counter-intuitive (Percentages can be treated as division, division before subtraction, lots of stuff is broken).
@ThePumpkin5822 Please refer to this image
You're saying math is useless? Brilliant. @bensku What are your thoughts on this?
Where did you get that?
You are enforcing your point with the image that 1% is 0.01 regardless of the fact the value should be of the original number. Since adding percentages as their are now would be useless because it's not only invalid, there's already a way to do that within Skript.
I have no idea when Skript's behavior changed, but Skript is correct that 1% is 0.01. What you want instead is an expression that provides the value for x% of %number% where x is some number - which Skript as of 2.4 does not have. As such, I'll mark this as an enhancement request.
@Wealthyturtle After looking at it, this does look weird to me, as a standard calculator would get 99 from this, not 99.99 (Source: Samsung A6 built-in calculator, WolframAlpha, Google)
¯_(ツ)_/¯
I feel like 1% is not equal to any number, if no context is given. A percentage is a number to describe a part of a whole, and is therefore not equal to any number. If you use it in a calculation, such as 500 + 1%, the percentage (1%) would represent 1% of the 500, so the 1% is in this scenario equal to (1/100 * 500), so 500 + 1% should return 505.
This can be implemented, but it would probably require a new type for percentages, which can be used in some of the arithmetic expressions (or you add an optional percentage sign to the required arithmetic expressions).
I suggest not changing this behavior
percents should always be used with a value multiplied by it
that code above is hard to understand anyway
Rule of thumb: if you use sufficient parenthesis, Skript will eventually do what you want it to
Most helpful comment
I feel like 1% is not equal to any number, if no context is given. A percentage is a number to describe a part of a whole, and is therefore not equal to any number. If you use it in a calculation, such as
500 + 1%, the percentage (1%) would represent 1% of the 500, so the 1% is in this scenario equal to(1/100 * 500), so500 + 1%should return 505.This can be implemented, but it would probably require a new type for percentages, which can be used in some of the arithmetic expressions (or you add an optional percentage sign to the required arithmetic expressions).