Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialect 1. Not consistent result of two expressions with divide of NUMERIC with scale [CORE6481] #6712

Open
firebird-automations opened this issue Feb 3, 2021 · 0 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @ibprovider

Not consistent result of two expressions with divide:

1. cast(2 as NUMERIC(2, 1)) / cast(3 as NUMERIC(2,0))

returns DOUBLE value: 0.6(6) without any information about scale

2. cast(cast(2 as NUMERIC(2, 1)) / cast(3 as NUMERIC(2,0)) AS VARCHAR(32))

returns VARCHAR value: 0.7

---------------
d:\Program_Files\Firebird_3_0_x64>isql
Use CONNECT or CREATE DATABASE to specify a database
SQL> CONNECT "inet4://localhost/d:\database\RAM\IBP_TEST_FB30_D1.GDB";
Database: "inet4://localhost/d:\database\RAM\IBP_TEST_FB30_D1.GDB", User: HOME4\DIMA
SQL> SET SQLDA_DISPLAY ON;
SQL> select cast(2 as NUMERIC(2, 1)) / cast(3 as NUMERIC(2,0)) from dual;

INPUT message field count: 0

OUTPUT message field count: 1
01: sqltype: 480 DOUBLE scale: 0 subtype: 0 len: 8
: name: DIVIDE alias: DIVIDE
: table: owner:

             DIVIDE

=======================
0.6666666666666666

SQL> select cast(cast(2 as NUMERIC(2, 1)) / cast(3 as NUMERIC(2,0)) AS VARCHAR(32)) from dual;

INPUT message field count: 0

OUTPUT message field count: 1
01: sqltype: 448 VARYING scale: 0 subtype: 0 len: 32 charset: 0 NONE
: name: CAST alias: CAST
: table: owner:

CAST

0.7
-------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant