Login
You're viewing the gulp.cafe public feed.
  • Oct 28, 2026, 5:40 PM

    The correct naming scheme is so obvious it's left as an exercise for the reader. But I've always struggled with fixed-point. s16_16 has the ugly underscore, s1616 is hard to read, so I have settled on 16s16 as the inevitable truth. Now I just need more compilers to accept this wisdom.

    💬 1🔄 0⭐ 6

Replies

  • 💬 0🔄 0⭐ 0
  • Oct 28, 2026, 7:25 PM

    @petmac Obvious troll aside, my half-serious answer is - all integers are fixed-point numbers, they just have a fraction of zero. So the actual naming scheme I would use is i16_16, and i32 is just shorthand for i32_0.

    And my actual serious answer is that in practice I put the number of fractional bits in the VARIABLE, not the TYPE. So in fact 16_16 looks like:

    i32 someValue16;

    (I did try putting it in the type and having type-safe blah blah and all magically work and in practice it's a PITA)

    💬 1🔄 0⭐ 1
  • Oct 28, 2026, 7:28 PM

    @petmac For anyone wondering why I do so much fixed-point work - it's all when doing retro 68000 code.

    In my day job I do keep talking about fixed point for world position and time, but those are nicely wrapped up in their own classes and nobody else needs to know or care about the details because they're all hidden inside the class. I'm eccentric, not insane.

    💬 0🔄 0⭐ 1
  • Oct 28, 2026, 8:13 PM

    @TomF I've unironically given this a lot of thought and my best solution is that fixed point types should be typedef'd semantically rather than based on storage

    💬 1🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0