Skip to content

Add Bitwise Operations concept - #716

Merged
SleeplessByte merged 7 commits into
exercism:mainfrom
colinleach:bits
Mar 11, 2026
Merged

SleeplessByte merged 7 commits into
exercism:mainfrom
colinleach:bits

Conversation

@colinleach

Copy link
Copy Markdown
Contributor

I hope I understand this topic somewhat better than I understand Unicode (a low bar).

Comment thread concepts/bitwise-operations/introduction.md Outdated
Comment thread concepts/bitwise-operations/about.md Outdated
Comment thread concepts/bitwise-operations/about.md Outdated
Comment on lines +21 to +22

Perhaps surprisingly, `Byte` or `Short` types are not compatible with most bitwise operations in Kotlin.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Perhaps surprisingly, `Byte` or `Short` types are not compatible with most bitwise operations in Kotlin.
Perhaps surprisingly, `Byte` or `Short` types are not compatible with most bitwise operations in Kotlin.

I didn't know this!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Since 1.5, UByte has or and xor and and and inv, same for UShort.
Byte has full support since 1.2, same for Short.

@colinleach colinleach Sep 2, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's strange. The 2.2 docs say:

Bitwise operations are represented by functions that can be called in infix form. They can be applied only to Int and Long

I tried Byte and UByte in Kotlin Notebook, and couldn't get them to work with shl: "Unresolved reference. None of the following candidates is applicable because of receiver type mismatch".

I'm not getting much done today (reasons including all-day headache and brain fog), but I don't think I messed that up.

@SleeplessByte SleeplessByte Sep 3, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yoooo my Short link actually linked to BigInteger which is also new to me.... we now need to update the numbers concept XD. BigDecimal also exists nvm, only JVM!

Anyway, yeah, it works for UShort and UByte. Not Short and Byte. And not all operations are supported for UShort and UByte! Only and, or, xor, and inv. Playground. This playground also compiles in JS and Wasm :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, producing a clear, concise Concept for a poorly documented mess could be ... challenging.

Still, we're all better informed now, I suppose.

@colinleach colinleach Sep 3, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: feel free to disagree, but I have some doubts about whether experimental and undocumented features belong in an Exercism syllabus. Though maybe I'm just old and unimaginative...

(I'm definitely old)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I have some doubts about whether experimental and undocumented features

Experimental: maybe but I don't do that for the other tracks because it's a lot of work to keep track of.
Undocumented: sometimes, but in this case it's not undocumented. The Kotlin docs are out of date, the kotlin reference is not! That's how I found these: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-u-byte/#-1940364782%2FFunctions%2F-1430298843

Comment thread concepts/bitwise-operations/about.md Outdated
colinleach and others added 3 commits September 2, 2025 16:00
Co-authored-by: Derk-Jan Karrenbeld <derk-jan+github@karrenbeld.info>
Co-authored-by: Derk-Jan Karrenbeld <derk-jan+github@karrenbeld.info>
Co-authored-by: Derk-Jan Karrenbeld <derk-jan+github@karrenbeld.info>
@kahgoh kahgoh mentioned this pull request Oct 10, 2025
@kahgoh

kahgoh commented Oct 10, 2025

Copy link
Copy Markdown
Member

@colinleach, @SleeplessByte If there is still any interest in this concept, I've started porting Secrets for this (#720)

@colinleach

Copy link
Copy Markdown
Contributor Author

Apologies again for my abrupt disappearance about 5 weeks ago. Not intentional, just a sequence of health problems (minor, but one damn thing after another...)

I'd still love to reactivate this syllabus asap, and am very happy to see anyone else contribute during my enforced down-time.

Please don't count on me just yet. I'm poking at a few Julia practice exercises meanwhile, but they need a lot less mental energy than creating a Kotlin syllabus.

@SleeplessByte

Copy link
Copy Markdown
Member

I'm going to merge this to have it in the codebase. I think it's good enough to work with.

@SleeplessByte
SleeplessByte merged commit 0fd869b into exercism:main Mar 11, 2026
2 checks passed
@colinleach

Copy link
Copy Markdown
Contributor Author

Again, I can only offer my apologies for suddenly disengaging. Growing old (I'm 69) is better than failing to, but bodies and brains become less reliable with age. I'll do what I can, when I can...

@SleeplessByte

Copy link
Copy Markdown
Member

@colinleach you did great!!

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.

3 participants