On Mon, Sep 20, 2010 at 07:35:51AM +0000, Guangcong Luo wrote:
> 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

Right, lets do that, or until we get there stuff it in functions, e.g.:
> int fixed_mul(int a, int b);
> int fixed_div(int a, int b);

> 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?

Except that '>> fixed_point_bits' and '/ (1 << fixed_point_bits)' are
used interchangeably making it a *lot* harder to ignore.  Secondly, even
in places where one or the other is used consistently it isn't easy to
ignore.

>> 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.

Right, that'd be CPU's, all GPU-side computations *only* result in
graphics for our purposes.

> 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.

Except that we never used floats to store HP, experience or power (and
never should use floats for that), so those points are moot.  My
argument is about using floats for geometry, that's where floats shine
as long as all geometry resides in a limited space.  And currently all
our geometry *does* reside in a limited space: the map boundaries.

> The only advantage of floating 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.

Actually it stores small and large values at the *same* precision.
Which *is* needed in practice, in our case it's needed for rotations
(cos/sin).

>> 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

Right, and most geometric math (with translations as the *only*
exception) involves multiplication and division.

-- 
Giel
--
"Computer Science is no more about computers than astronomy is about
 telescopes."
  -- Edsger Dijkstra

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev

Reply via email to