I've been watching the Odd Number thread and now the MOD thread for a while now and I'm posting now to as people to drop both topics.

Here's a story..

Many years ago (1981), I was selling electronics, including computers. Although I knew the product pretty well I did not know anything about the internal workings of the operating system or the details of representing decimal numbers using binary arithmetic. A person kept coming into the store and tapping away at the display computer to write a small program. This is long before the internet and thoughts of malicious code etc. His program was specifically designed to show that when doing apparently simple arithmetic the computer would make tiny errors. His software was set up to amplify those errors and the end result was that the computer claimed that 2 multiplied by 3 gave a result of 5.9999999998 or something. He seemed very proud to have discovered our computer to be so faulty and announced that computers in general were flawed and not to be relied upon. He suggested that when the tax office sent us a computer generated assessment of our tax bill we should show them his program and declare loudly that binary computers did not understand decimal mathematics and so on.

The problem was, when told of this, the tax office would declare the speaker to be a nut.

The irony is...the tax office was right.

We should all accept that there are inherent problems trying to describe the infinity of numbers in a universal format. Try representing one third as a decimal. You will soon run out of paper (or computer memory) as you write an endless list of 3333333333's. so at some stage you will say "enough is enough...I have described this number to so many decimal places that I'm close enough for all practical purposes." Then take the result you decided on and multiply it by 3. Logic tells you that it should equal 1 but reality shows you it will be .9999999999999999...9999999" and so on depending on where you decided "enough is enough"

Nobody here has discovered any "bug" in Liberty Basic. They have simply re-discovered the problems that arise when you try to represent the infinity of numbers in the finite space of binary logic when limited by a finite size to represent each number. I guess if I looked hard enough I could discover that when my car Speedo said I was doing 60Mph I was actually doing 59.9998763624. So what. I don't care about this tiny level of error. It will not get me off that speeding fine I got last week. The tax office does not care if their assessment is inaccurate by .000000000001 cents. They just want me to pay my tax bill.

I accept that some people can write a program specifically to expose the errors produced when binary numbers are used to represent numbers in the real world. Congratulations to them...they have performed a significant academic exercise. But let's not confuse their ability to write these programs with their ability to expose any real-world implications of these errors.

----- Original Message -----

From: Nick Fraser

To: libertybasic@yahoogroups.com

Sent: Wednesday, August 01, 2007 6:48 PM

Subject: [libertybasic] MOD

This question has arisen from the Odd number thread.

How come the following code:

'***********************************

struct qaz, a as double, b as double, c as double, d as double, e as

double

a=1.9999999999

b=2.9999999999

c=2.5

d=3

a= a mod 2

b= b mod 2

c= c mod 2

d= d mod 2

print a,b,c,d

'************************************

produces the following as an output?

2.0 1.0 0.5 1

Thanks

Nick

[Non-text portions of this message have been removed]