On Sun, Sep 19, 2010 at 6:42 PM, Giel van Schijndel <[email protected]> wrote: > Right, my main point against all that fixed point math is that it > disguises the actual math going on by adding loads of shifts and muls > only to correct for the fixed point offsets. > > E.g. a simple mul 'a * b' becomes '(a * b) >> fixed_point_bits'.
Well, we're slowly moving to C++. Once we get there, we could just redefine operators! :D Anyway, just ignoring ">> fixed_point_bits" makes it pretty readable, even in C. I guess in situations where it's hard to read, put what's going on in comments? > Moreover, *why* does it need to be in fixed point? I know rounding > errors can occur with floats, but that's what epsilon's for, to enable > range-comparisons [1]. >From what I heard from Cyp, there are apparently bugs in some processors (or graphics cards or something) that lead to floating point calculations to be nondeterministic, which causes sync problems in newnet. There are also some other things I personally don't like about floating point: It's decent for multiplication/division, but not very good for addition/subtraction. A lot of what we use floating/fixed point for is stuff like storing HP or experience or power, which we add and subtract a _ton_, and that's where fixed point shines. The only advantage of floating point (aside from C's poor support for human-readable fixed point) is the ability to store large values at low precision and small values at high precision in the same data type, which is pretty much never needed in practice. > So *if* there's a good reason for using fixed point math, then at least > reduce the risk of it introducing and disguising bugs by using some > decent fixed-point library. But don't scatter all that fixed-point crap > all over the code as it messes with the way we've all learned to think > about basic mathematical operations. I like the "fixed point library" idea. Also: Fixed-point only messes with the way we've learned to think about multiplication and division. Addition and subtraction work normally! :D -Zarel _______________________________________________ Warzone-dev mailing list [email protected] https://mail.gna.org/listinfo/warzone-dev
