Posts by harold@mastodon.gamedev.place
(DIR) Post #Aw1ftGLtcSVwk0WXoW by harold@mastodon.gamedev.place
2025-07-11T14:08:41Z
0 likes, 0 repeats
@wolf480pl uh apparently they were called clockwise intervals, but whatever. Roughly they're intervals/ranges with a convention that if the lower bound is higher than the upper bound, it means the range spans across the highest integer and wraps back around
(DIR) Post #Aw1gophEsnDwrixU5A by harold@mastodon.gamedev.place
2025-07-11T14:19:06Z
0 likes, 0 repeats
@wolf480pl something like that but it's not properly a lattice operation, here's some example from "Signedness-Agnostic Program Analysis: Precise Integer Bounds for Low-Level Code"
(DIR) Post #AwS1wiFXsSlVAefSoy by harold@mastodon.gamedev.place
2025-07-24T01:46:04Z
0 likes, 0 repeats
Memory renaming has made the so-called "fastcall" calling convention a bit of a joke, as another joke I wrote some "what if stdcall but 64-bit" code and it was slightly faster...
(DIR) Post #Ax7iHEiBFYeBCIhqLI by harold@mastodon.gamedev.place
2025-08-13T09:45:14Z
0 likes, 0 repeats
Java is so big-endian-brained that its BigInteger implementation has the least significant limb at the highest index. Various parts of the code serve as an example of why you don't want to do it that way.
(DIR) Post #Ax8kTBXRGfkJtgT1Ye by harold@mastodon.gamedev.place
2025-08-13T21:55:05Z
0 likes, 0 repeats
@wolf480pl @nh I've done a proof-by-SAT-solver that you need 6 XORs for N=3 and 9 XORs for N=4, N=5 is looking a little hard (for this encoding+solver anyway, and I just realized that this encoding is stupid), there's no sequence of 10 XORs but 11 is still in the process of being disproven.If the answer is going to be as nice as "3(N-1) for any N" surely there's some way to prove it
(DIR) Post #AxZDnLRc61PFBzfKU4 by harold@mastodon.gamedev.place
2025-08-26T16:20:34Z
0 likes, 0 repeats
Some languages have 1 "kind" of fized-sized integer (let's forget about 0) like Java (and let's forget about "ackchyually char is "), mostly "well you have signed integers, you can use them as unsigned but it's awkward across interface boundaries", some have 2 (signed/unsigned), what about 3: signed/unsigned/bitvectorAnd no I don't mean "like C++ because it has std::bitset<N>", I mean a proper integer type (add, multiply, other integers implicitly convert to it) with no signedness
(DIR) Post #AxZEqdQVnLm9moHblo by harold@mastodon.gamedev.place
2025-08-26T16:37:58Z
0 likes, 0 repeats
@wolf480pl well I didn't mean "add = xor" (and presumably mul=clmul?), that's fun too but I don't think common enough to promote to a built-in type this way, more something along the lines of "doesn't commit to having a signed or unsigned interpretation" - useable when signedness is irrelevant (eg can be added or multiplied the same way other integers do, but doesn't implicitly sign-extend or zero-extend, has no default order, cannot be divided, that sort of thing but the details are negotiable)
(DIR) Post #AxZFD55NdhyTwN6O5g by harold@mastodon.gamedev.place
2025-08-26T16:42:02Z
0 likes, 0 repeats
@wolf480pl I'd even say, it's neither. Imagine if signed and unsigned integers derived from a common class that has the shared behavior of signed and unsigned integers but not anything that's different
(DIR) Post #AxZHz86Fw5ot64YCuG by harold@mastodon.gamedev.place
2025-08-26T17:13:07Z
0 likes, 0 repeats
@wolf480pl perhaps there could be explicit sign and zero extensions, if that's what we want, but the type itself wouldn't make the choice between them
(DIR) Post #AxZJ9NpqO4d4kVKMIy by harold@mastodon.gamedev.place
2025-08-26T17:26:09Z
0 likes, 0 repeats
@wolf480pl every fixed-size integer is already a bitvector from a compiler's perspective so it wouldn't help in that senseBut yes, what are the consequences. Various functions could be written "signedness-generically" if that's what we wanted (but do we?) which is essentially the status quo in "1 kind of integer"-languages like Java but you have to pretend the types are signed. Perhaps it provides an answer to "what do you get when you add s32 to u32" (could widen to s64, or go no-signedness)
(DIR) Post #Ay7yChwamX5TTmpDoe by harold@mastodon.gamedev.place
2025-09-12T10:43:06Z
0 likes, 1 repeats
- `interface IVisitor` with dozens of overloads of Visit- dozens of classes that each have their method that merely calls the right overload on an IVisitor- a class that implements IVisitor that is really a single method in disguise but with its contents confettified into dozens of method-in-name-only methodsOmni-Man to Invincible (labeled "sum types and pattern matching"): "Look what they need to mimic a fraction of our power"
(DIR) Post #AyCK7tV47A6RNiXAHY by harold@mastodon.gamedev.place
2025-09-14T13:10:50Z
0 likes, 0 repeats
@wolf480pl again, or the one from a couple of years ago? Either way, lame
(DIR) Post #AywMrPqu0vILgtaKMC by harold@mastodon.gamedev.place
2025-10-06T12:36:27Z
0 likes, 0 repeats
Blogged in anger: The non-problem of unsigned integers in Javahttps://bitmath.blogspot.com/2025/10/the-non-problem-of-unsigned-integers-in.html
(DIR) Post #B1EYGess7ZXVNUp1ge by harold@mastodon.gamedev.place
2025-12-14T07:57:54Z
0 likes, 0 repeats
Imagine a processor that can push and pop relatively efficiently, but cannot efficiently do random-access on the stack. Also, you only have approximately 3 and half registers. You can swap one of them with top-of-stack but it's on the slower side. Or don't imagine, because it's real..Hypothetically (or not), how would you deal with that in a compiler?(allocating local variables globally and making functions non-reentrant is considered cheating)
(DIR) Post #B1O7poq4LYs9CpeSn2 by harold@mastodon.gamedev.place
2025-12-18T21:32:02Z
0 likes, 0 repeats
Fun problem: test if `x` is equal to `y` or any of its bitwise prefixes.A value that you can reach from `y` by applying `y &= y - 1` some number of times is a prefix of `y`.0 is a prefix of anything. The prefixes of 15 are 15 itself, 12, 8, and 0. The prefixes of 0b101101 are 0b101101, 0b101100, 0b101000, 0b100000, and 0b000000.You can do the test in 3 arithmetic operations and a comparison, good luck
(DIR) Post #B1O7pwzw0lW8VkKSHI by harold@mastodon.gamedev.place
2025-12-18T21:39:05Z
0 likes, 0 repeats
Bonus round: by going up to 4 arithmetic operations and a comparison, you can do a similar test that considers 0 to be a prefix only of 0, not also of all other numbers.
(DIR) Post #B1Oxo4fNiy6TKd8rY0 by harold@mastodon.gamedev.place
2025-12-19T09:08:19Z
0 likes, 0 repeats
@wolf480pl this is pretty close to solving the bonus round
(DIR) Post #B1ZZgi5PHlpNa2aJSi by harold@mastodon.gamedev.place
2025-12-24T11:42:13Z
0 likes, 0 repeats
I understand some languages' disapproval of implicit narrowing conversions, but if I write `num >> 24` there is really no issue here, especially not:"note: unsigned 8-bit int cannot represent all possible unsigned 32-bit values"I get it, it's annoying to have to nail down a KnownBits analysis pass to such a degree that you can add it to a language specification without it being unpredictable and unreliable. But can you give me *something*, for ergonomics?
(DIR) Post #B1ZZgkGTBbriKvmAz2 by harold@mastodon.gamedev.place
2025-12-24T11:49:53Z
0 likes, 0 repeats
The error message explicitly mentioning values is more of a misdirection than if it only mentioned type-incompatibility
(DIR) Post #B2IzxgjXaTHGHZcsme by harold@mastodon.gamedev.place
2026-01-15T09:45:12Z
0 likes, 0 repeats
V8 asm output is .. well decide for yourself what this is.Take 83f1ff, rendered as xorl rcx,0xffIf you can read the machine code, you know that's actually xor ecx, -1.