Skip to content

Conversation

Wide-Cat
Copy link
Collaborator

@Wide-Cat Wide-Cat commented Sep 4, 2025

Tried to follow Java syntax, but due to the ^ symbol already being used as the exponentiation operator I had to improvise for Xor. Happy to hear other suggestions but I thought this was one of the better compromises. Redefining ^ to be used for Xor and adding something else for exponentiation isn't really an option as it would break existing scripts.

Have to cast the arguments into longs since you can't perform bitwise operations on floating point types. Should we do this and silently floor the arguments, or should we restrict these operators to only be used on whole numbers and error otherwise?

Additions:
& - Bitwise And
| - Bitwise Or
|^ - Bitwise Xor
~ - Bitwise Not
<< - Left shift
>> - Signed right shift
>>> - Unsigned right shift

@chri-k
Copy link
Contributor

chri-k commented Sep 5, 2025

note: the second-most-common symbol for xor across languages (after ^) is~ (since not is just xor with a constant, as negation is just subtraction form a constant)

@moxvallix
Copy link

Maybe ^^ works?

GreemDev referenced this pull request in GreemDev/Starscript.Net Sep 11, 2025
bitwise xor uses ^ now, use ^^ for exponents in math
@GreemDev

This comment was marked as resolved.

@Sennadachi
Copy link

it is a good idea

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

Successfully merging this pull request may close these issues.

6 participants