Subject Strange problem using Firebird embedded 2.5 x64 in 64 bits windows platform
Author Chee Yang
I am using Firebird 2.5 Embedded in 64 bits windows platform.

I compile my application with Firebird embedded using Delphi XE2 64 bits platform.

I create a table:

CREATE TABLE T_TEST1 (
DTLKEY INTEGER NOT NULL,
CURRENCYRATE DECIMAL(14, 6),
AMOUNT DECIMAL(16, 2),
SQTY DECIMAL(18, 4),
PRIMARY KEY(DTLKEY)
)

Insert a row to table:

INSERT INTO T_TEST1 (DTLKEY, CURRENCYRATE, AMOUNT, SQTY)
VALUES (1, 9011.2, 1482.8, 1)

I then execute a SQL Query:

SELECT CAST(Amount * CurrencyRate AS DECIMAL(18, 8)) / SQTY FROM T_TEST1

I receive a strange value from the select query.

In 32-bits windows, I will encounter error (this is expected error):

Arithmetic overflow or division by zero has occurred.
arithmetic exception, numeric overflow, or string truncation.