Live data from Hacker News

The fixed_point C++ Class Template

github.com

21–23 of 23 posts

Re: The fixed_point C++ Class Template

#21
post #7

The negative exponent bothers me. Every implementation I've used specifies either mantissa bits or exponent bits, as a positive value. The extraneous '-' everywhere feels like a waste

I don't understand your complaint... A waste of what? You'd rather have all values expressed in terms of just raw bits?

Re: The fixed_point C++ Class Template

#22
post #12
post #6

I was having trouble understanding why fixed-point arithmetic was particularly useful in game development. In fact, I was curious why fixed point representation was more useful than floating point at all... Two links deep, I found [1]. The salient being "...floating point representation gives you extra precision for numbers near zero, this extra precision comes at the expense of precision for numbers further out" 1.…

The most useful feature of fixed point calculations is its deterministic nature. Determinism is necessary when multiple parties need to be in the same state, with the state being too large to be exchanged between the parties. The canonical example are RTS style games where there are hundreds of units, but only the actions of the players are sent to every other players. The result of the actions are computed independe…

The idea that floating point isn't deterministic is patently false. If it wasn't, that'd mean that every computer adds random noise to the calculation. That's nonsense. This myth seems to be propagated because fp is hard to work with and has a lot of quirks: its non uniform division of space, the x87 extended precision mode, the various rounding modes... But none of that stuff is intractable.

(Many games have shipped with fp in networked code. see http://gafferongames.com/networking-for-game-programmers/flo... and look for previous discussion here on HN, reddit...)

Re: The fixed_point C++ Class Template

#23
post #7

The negative exponent bothers me. Every implementation I've used specifies either mantissa bits or exponent bits, as a positive value. The extraneous '-' everywhere feels like a waste

Given there are no exponent bits (all of the bits are effectively mantissa bits with no hidden bit), your plan doesn't seem to make sense.

The numbers are (integer_value * 2 ^ constant_exponent), such that all bits are dedicated to integer_value.

Post reply on HN