floats or ints? (Re: [computer-go] Re: Remarks on the Indigo-Paper)

William Harold Newman william.newman at airmail.net
Tue Jun 20 12:21:24 PDT 2006


On Tue, Jun 20, 2006 at 10:18:30PM +0200, Chrilly wrote:
> Once upon a time floats were rather slow. This is not the case anymore. But 
> I can see no advantage, ints are even nowadays more flexible. E.g. its not 
> possible to use a float as an array-index, there are no bitwise 
> operations.... and one gets some problems with rounding errors.
> 
> Gnu-Go uses floats. Maybe could someone of the team explain the rationale 
> behind this choice.

(I'm not on the Gnu Go team, just answering the question from my 
own perspective.)

I have done it both ways in various programs. Currently I don't see a
compelling reason to go either way. Of the top of my head, here are
some (admittedly minor) advantages for floats:
  * It's easy to feed floats into standard implementations of special 
    functions like sqrt and log.
  * It's easy to feed floats into standard implementations of numeric 
    transformations like FFT.
  * It's easier to read some kinds of expressions when you don't need
    to think about reintroducing exactly the right number of 
    fixed-point denominators. For example, imagine several
    values which represent subprobabilities, like the probability
    of making an eye and the probability of connecting a pair of chains.
    An expression combining such subprobabilities, perhaps into the 
    overall probability of making life under the approximation that 
    all the subprobabilities are independent, tends to be relatively 
    easy to write and check for floats, and noticeably more tedious 
    for fixed point fractions embedded in ints.
(And you've already pointed out some comparable advantages for ints.)

-- 
William Harold Newman <william.newman at airmail.net>
PGP key fingerprint 85 CE 1C BA 79 8D 51 8C  B9 25 FB EE E0 C3 E5 7C
Ubi saeva indignatio ulterius cor lacerare nequit. -- Jonathan Swift's epitaph


More information about the computer-go mailing list