Subject | Another silly precedence issue |
---|---|

Author | Stephen Boyd |

Post date | 2006-10-19T19:03:39Z |

I find arithmetic operator precedence defined in various sets of

Interbase and Firebird documentation as follows:

Multiplaction - 1

Division - 2

Addition - 3

Subtraction - 4

This goes against standard algebraic rules where multiplication and

division have the same precedence (1) and are followed by addition and

subtraction which have the same precedence (2).

A quick test shows that Firebird actually follows the algebraic rules

and not the precedence given above.

select 4.0 / 8.0 * 2.0 from rdb$database yields 1.0, NOT 0.25 which

would be the result obtained by following the precedence given in the

documentation.

I can only assume that this is just a silly documentation mistake that

has propogated forward from time immemorial. I am only concerned

about this because I am trying to create a short embedded SQL

programming guide and I want to get it right.

Comments?

Interbase and Firebird documentation as follows:

Multiplaction - 1

Division - 2

Addition - 3

Subtraction - 4

This goes against standard algebraic rules where multiplication and

division have the same precedence (1) and are followed by addition and

subtraction which have the same precedence (2).

A quick test shows that Firebird actually follows the algebraic rules

and not the precedence given above.

select 4.0 / 8.0 * 2.0 from rdb$database yields 1.0, NOT 0.25 which

would be the result obtained by following the precedence given in the

documentation.

I can only assume that this is just a silly documentation mistake that

has propogated forward from time immemorial. I am only concerned

about this because I am trying to create a short embedded SQL

programming guide and I want to get it right.

Comments?