Skip to content

Fix incorrect power of two operator - #56

Merged
metux merged 1 commit into
X11Libre:masterfrom
dec05eba:fix-pow2
Jun 13, 2025
Merged

Fix incorrect power of two operator#56
metux merged 1 commit into
X11Libre:masterfrom
dec05eba:fix-pow2

Conversation

@dec05eba

@dec05eba dec05eba commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

2^16 is 2 xor 16 which equals 18, not 2 to the power of 16 which is 65536

@metux
metux force-pushed the xlibre/prepare branch 2 times, most recently from 415757a to 0cafe94 Compare June 11, 2025 09:55
@metux

metux commented Jun 11, 2025

Copy link
Copy Markdown
Contributor

Why is 2^16 wrong ? Shouldn't it result in exactly the same ?

@metux metux added the janitor Minor cleanups helping to improve overall code quality. label Jun 11, 2025
@dec05eba

Copy link
Copy Markdown
Contributor Author

Why is 2^16 wrong ? Shouldn't it result in exactly the same ?

Because 2^16 isn't a power of two operation, it's 2 xor 16, which equals 18. Gcc 15.1 gives a warning about this.

@Kreijstal

Kreijstal commented Jun 11, 2025

Copy link
Copy Markdown

maybe we just want max connections 18? :D

Why is 2^16 wrong ? Shouldn't it result in exactly the same ?

no it is definitely not the same ^ is xor not pow

@metux

metux commented Jun 11, 2025

Copy link
Copy Markdown
Contributor

Why is 2^16 wrong ? Shouldn't it result in exactly the same ?

Because 2^16 isn't a power of two operation, it's 2 xor 16, which equals 18. Gcc 15.1 gives a warning about this.

uuups, you've cought me. I'm covering my head in a paper back and silently moving to some dark corner where nobody can see me ;-)

I yet need your sign-off, btw.

@metux metux added bug Something isn't working and removed janitor Minor cleanups helping to improve overall code quality. labels Jun 11, 2025
@dec05eba

dec05eba commented Jun 11, 2025

Copy link
Copy Markdown
Contributor Author

I yet need your sign-off, btw.

Added. Or do we need to use real names?

@xorgy

xorgy commented Jun 11, 2025

Copy link
Copy Markdown

‘18 connections ought to be enough for anybody’ ― Enrico Gates

@metux

metux commented Jun 12, 2025

Copy link
Copy Markdown
Contributor

‘18 connections ought to be enough for anybody’ ― Enrico Gates

uuuh, do I become a billionare now ? ;-)

@metux

metux commented Jun 12, 2025

Copy link
Copy Markdown
Contributor

uh, it needs a rebase, because I had to fix up the history (see mail)

@dec05eba
dec05eba changed the base branch from xlibre/prepare to master June 12, 2025 19:22
@dec05eba

Copy link
Copy Markdown
Contributor Author

@metux done

2^16 is 2 xor 16 which equals 18, not 2 to the power of 16 which is 65536

Signed-off-by: dec05eba <dec05eba@protonmail.com>
@metux

metux commented Jun 13, 2025

Copy link
Copy Markdown
Contributor

If we ever have conference, I want a t-shirt with that quote I have never said ;-)

@metux
metux merged commit 8c3c20f into X11Libre:master Jun 13, 2025
@metux metux added this to the 25.0 milestone Jun 17, 2025
@overtube

Copy link
Copy Markdown

if put that in calculator — answer is 2^16 = 65536.

@sskras

sskras commented Jul 5, 2025

Copy link
Copy Markdown

Added. Or do we need to use real names?

That's a very reasonable question, BTW, fundamental to the project mgmt.
Eg. Wine project demands a contributor to identify oneself by one's name(s) and the surname.

@metux: does the XLibree fork allow to contribute anonymously?

@metux

metux commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

@metux: does the XLibree fork allow to contribute anonymously?

Some unique name and a valid mail address (where you can be reached) is enough.

@Lumios64

Lumios64 commented Jul 7, 2025

Copy link
Copy Markdown

Bitwise xor is fairly uncommon, and if we assume it was the default behavior of xorg, this is gonna introduce incompatibilities between software run in xorg's xserver versus X11Libre's xserver. The last thing we need is another Wayland situation.

Regardless, if you are planning to move forward with this commit, it would be wise to add a replacement for the old behavior. C# also uses ^ for bitwise xor, but it has math.pow() that does essentially the same thing ^ did before this issue.

@sskras

sskras commented Jul 8, 2025

Copy link
Copy Markdown

if we assume it was the default behavior of xorg, this is gonna introduce incompatibilities between software run in xorg's xserver versus X11Libre's xserver

You could simply check date of the last change / when did it was introduced. The line comes from 2025-06-12:
https://github.com/dec05eba/xserver/commit/415594fd67a36cb6c49d18eb3d3299055e38dce2#diff-5e4ee80ed44ada865ec91ea64915a0e0ba08b33dfdae64887b7c91d98b107350R153-R162
... it's only ~ one month old, so no worries. And no need for assumptions. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants