Subject | 3 * 1/3 = 0 ??? |
---|---|

Author | rogervellacott |

Post date | 2002-08-30T14:06:38Z |

I always thought this was true

(1/3)*3 = 1

But Interbase and Firebird (and probably all the other RDBMSs) say

this equals 0.

Try

SELECT (1/3)*3 FROM RDB$DATABASE

I know there was some discussion of this on this group some time ago,

and no doubt some convincing explanations were given, but I am a

simple soul, and the more I try to cope with it, the more obviously

wrong it is.

Did you know that

1/3.00 = 0.33

and

1.00/3 = 0.33

You might think this was a useful way of rounding. But no,

3.333333/1.00 = 3.33333300

so unless you have already determined how many decimal places there

are in every element of your formula, you cannot know how many

decimal places there will be in the answer.

In my view, this behaviour invites errors. Not only is it

unintuitive, it gives the wrong answers to simple calculations, and

unpredictable answers to complex calculations, and that is not a good

idea.

Any chance of changing it next version? If integer operations are

desired, how about a div? Please don't tell me that current

behaviour is good. It isn't.

(1/3)*3 = 1

But Interbase and Firebird (and probably all the other RDBMSs) say

this equals 0.

Try

SELECT (1/3)*3 FROM RDB$DATABASE

I know there was some discussion of this on this group some time ago,

and no doubt some convincing explanations were given, but I am a

simple soul, and the more I try to cope with it, the more obviously

wrong it is.

Did you know that

1/3.00 = 0.33

and

1.00/3 = 0.33

You might think this was a useful way of rounding. But no,

3.333333/1.00 = 3.33333300

so unless you have already determined how many decimal places there

are in every element of your formula, you cannot know how many

decimal places there will be in the answer.

In my view, this behaviour invites errors. Not only is it

unintuitive, it gives the wrong answers to simple calculations, and

unpredictable answers to complex calculations, and that is not a good

idea.

Any chance of changing it next version? If integer operations are

desired, how about a div? Please don't tell me that current

behaviour is good. It isn't.