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

Firebird float support does not conform to Interbase spec [CORE2315] #2739

Closed
firebird-automations opened this issue Feb 10, 2009 · 12 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Bill Oliver (verbguy)

Assigned to: Bill Oliver (verbguy)

Is related to QA387

The Interbase documentation says that a float value should have a range from 1.175E-38 to 3.402E38. But, the largest value I can put in appears to be just under 3.4E38. 3.4E38 or higher results in overflow.

This came up when running the JDBCCTS tests against Firebird embedded. Thanks go to my co-worker Dave M.

This was fixed in SAS Vulcan (S0275993). The code in jrd/cvt.cpp is using hard-coded 3.4E38 instead of the proper FLT_MAX symbol which is 3.402823466e+38F. Fix provided to Alex for review.

Here is bad test case:

create table float_test (i integer, f float);
insert into float_test values (1, 3.0);
insert into float_test values (1, 3.402823466e+38);

produces this output:
insert into float_test values (1, 3.402823466e+38);
Statement failed, SQLSTATE = 22003
arithmetic exception, numeric overflow, or string truncation
-numeric value is out of range

Here is correct results with my patch:

SQL> create table float_test (i integer, f float);
SQL> insert into float_test values (1, 3.0);
SQL> insert into float_test values (1, 3.402823466e+38);
SQL> select * from float_test;

       I              F 

============ ==============
1 3.0000000
1 3.4028235e+38

Commits: d80913a

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

assignee: Bill Oliver [ verbguy ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Fincal patch is decided to be:

#⁠ifdef FLT_MAX
#⁠define FLOAT_MAX FLT_MAX /* Approx. 3.4e38 max float (32 bit) value */
#⁠else
#⁠define FLOAT_MAX 3.4e38 /* max float (32 bit) value */
#⁠endif

Added not to forget after beta1.

@firebird-automations
Copy link
Collaborator Author

Commented by: Claudio Valderrama C. (robocop)

Beware that the documentation says:

Of these macros, only FLT_RADIX is guaranteed to be a constant expression. The other macros listed here cannot be reliably used in places that require constant expressions, such as `#⁠if' preprocessing directives or in the dimensions of static arrays.

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

May be I'm dumb, but where do you see use of FLT_MAX with #⁠if or as static array index?

@firebird-automations
Copy link
Collaborator Author

Commented by: Bill Oliver (verbguy)

fixed for 2.5 RC 1

@firebird-automations
Copy link
Collaborator Author

Modified by: Bill Oliver (verbguy)

Fix Version: 2.5 RC1 [ 10362 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: Bill Oliver (verbguy)

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA387 [ QA387 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @pcisar

QA test added.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test => Done successfully

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