[Sussex] Challenge

Steve Dobson SDobson at manh.com
Wed Apr 30 10:38:00 UTC 2003


Geoff

On 30 April 2003 at 09:02 Geoff Teale wrote:
> Seems a long time since anyone has set a challenge to get Nik and Mark
> thinking and make Jon complain about the prominance of mathematical debate
> amongst list members.

Yes it does.
 
> So here's one...

Ohhhh a challenge

> Computer scientists often say that 10 times 0.1 very rarely 
> equals 1.0   All I want you to do is come up with a wholly
> accurate binary representation of the number 0.1 that can be
> used by normal floating point operators without the use of
> "fudge factors".  The proof is simple, it must in base 2 prove
> that the following base 10 equation is correct:
> 
> 10 * 0.1 = 1.0

Here is my solution when working in base 2 throughout:

$ bc
scale=99
ibase=2
obase=2
1.0 / 1010.0
1010.0 * (1.0 / 1010.0)
quit
$

Tested on a Sparc 64 (Solaris 8) and Cygwin and both produced 
a 1.0000...000 result.  I haven't published to output from 
bc, I'll leave that up to the judge.

Do I pass?

> .. most convincing arguement wins the notional pint - should 
> Pip win (most likely as she is often the only person to walk
> away from a LUG meet with her intellect untarnished) a non-
> alcoholic prize may be allocated ;) 

Mine's a pint of ale (Horsham Best Bitter is quite drinkable).

Steve

P.S. I think I still owe Pip a pint of water [before I get told 
     off].




More information about the Sussex mailing list