ID:2894832
 
Not a bug
BYOND Version:514
Operating System:Windows 10 Home 64-bit
Web Browser:Chrome 118.0.0.0
Applies to:Dream Seeker
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
the % operator does not return the proper value

Code Snippet (if applicable) to Reproduce Problem:
world.log << 6.5 % 2
world.log << 13 % 2


Expected Results:
0.25
0.5

Actual Results:
0
1


(i confirmed with a friend that it is still broken in the latest beta version)
Those results are correct. What do you think that operator does?

EDIT: I should clarify. 13 % 2 is always 1, for both integer and float modulo. In BYOND, % is integer modulo, so in 6.5 % 2, the 6.5 is truncated to 6, and 6 % 2 is 0. 6.5 % 2 would be 0.5 with float modulo, which is %% in BYOND.
Spevacus resolved issue (Not a bug)
Exxion is correct here. For legacy reasons, % is integer-only. In the documented case, A % B, A and B are truncated to integers. If you're intent on non-integer uses, use %%
that reference looks different than what shows up in the F1 menu of dream maker, so i didn't know about the integer thing

That's interesting. I'm on latest Beta and I've got the updated version:



On 514, the one you showed is displayed.

I suspect this is a case of 515 having the updated text that describes this integer-only functionality that existed but just wasn't explained.

Edit: Oh, it's because %% didn't exist in 514. Silly me.
i still don't understand why %% works the way it does

it says it returns the remainder of A / B, but that's wrong, it even says so in the line below
what it actually returns is B * (A / B), which makes no sense to me, because then to get the actual remainder you'd have to do (A %% B) / B
In response to RootAbyss
(A %% B) / B isn't the remainder; it's the remainder divided by B.
oh my god... i'm actually dumb
apparently i forgot what a remainder is and just thought it was any decimal point value after a division
my bad