why is the "round towards zero" operation not more common?
i'm looking at it specifically from a games programming lens but just in general.
is it just less useful than i imagine it to be?
too easy to implement yourself?
⬛🟪⬜🟨⬜🟪⬛
---
Avatar by @TuxedoDragon
---
General-interest posting,
art, casual devlogs,
serial collector of hobbies and projects.
For just gamedev see @sunfire-interactive
---
I jump between projects quite often, but here are some that I'm continuing to orbit around and will likely keep up with as long as I can.
Gamedev Projects:
Riptide Manor
Misc. Gamedev Resources
Worldbuilding Projects:
The King's Domain
The Roamer's Library
Custom Lego Themes:
Freeracers
TripleCross///
OverRiders///_
Other stuff:
Every Elden Ring character i've ever made
why is the "round towards zero" operation not more common?
i'm looking at it specifically from a games programming lens but just in general.
is it just less useful than i imagine it to be?
too easy to implement yourself?
At a hardware level it's expensive to implement, but I have no idea why it's not common further up he stack.
is the same true of other rounding functions?
i suppose as long as one of floor/ceiling/round is cheap then all of them are, basically, since you can just offset by 0.5 or 1
I guess I should clarify: it's expensive for fixed-point numbers, since truncating a 2's-compliment int by shifting it implements truncation rather than rounding. For floats, iirc, it's as cheap either way because they use sign bits without 2's-complement. But yeah, it's at least partially to save that additional arithmetic operation.
x64 and RISC-V both specify that floating point instructions (including integer conversion) should support round-to-zero as a rounding mode? I think it's just assumed and not explicitly called out in the floating point instructions themselves
(e: accidentally replied to the followup comment)