Issue Details (XML | Word | Printable)

Key: CORE-3091
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Adriano dos Santos Fernandes
Reporter: Karol Bieniaszewski
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Built-in function POWER(X, Y) does not work when the X argument is negative and the Y value is scaled numeric but integral

Created: 31/Jul/10 05:54 AM   Updated: 03/May/11 09:05 AM
Component/s: None
Affects Version/s: 2.1.3, 3.0 Initial, 2.5 RC1, 2.5 RC2, 2.5 RC3
Fix Version/s: 2.1.4, 2.5.1, 3.0 Alpha 1

Time Tracking:
Not Specified

Environment: Windows XP
Issue Links:
Relate
 

Planning Status: Unspecified


 Description  « Hide
this work
select power(3, 2) from RDB$DATABASE
select power(-3.0, 2) from RDB$DATABASE
select power(3.0, 2.0) from RDB$DATABASE

but this not work
select power(-3, 2.0) from RDB$DATABASE

SQL message -833
expression evaluation not supported
engine code 335544606

 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
GR added a comment - 21/Oct/10 11:41 AM - edited
In 2.1.4.18358 it is still not fixed:

select 'power( 2, 2 )', power( 2, 2 ) from RDB$DATABASE
union all
select 'power(3, 2)', power(3, 2) from RDB$DATABASE
union all
select 'power(-3.0, 2)', power(-3.0, 2) from RDB$DATABASE
union all
select 'power(3.0, 2.0)', power(3.0, 2.0) from RDB$DATABASE
union all
select 'power(-3, 2.0)', power(-3, 2.0) from RDB$DATABASE

returns

power( 2, 2 ) 0
power( 3, 2 ) 0
power(-3.0, 2 ) 0
power(3.0, 2.0) 0
power(-3, 2.0) 9

Karol Bieniaszewski added a comment - 27/Oct/10 06:36 AM - edited
I confirm this
patch fix problem only with this
select power(-3, 2.0) from RDB$DATABASE

but brake all others

select 'power( 3, 2 )', power( 3, 2 ) from RDB$DATABASE
union all
select 'power( -3, 2 )', power( -3, 2 ) from RDB$DATABASE
union all
select 'power( 3, -2 )', power( 3, -2 ) from RDB$DATABASE
union all
select 'power( -3, -2 )', power( -3, -2 ) from RDB$DATABASE
union all


select 'power( 3, 2.0 )', power( 3, 2.0 ) from RDB$DATABASE
union all
select 'power( 3, -2.0 )', power( 3, -2.0 ) from RDB$DATABASE
union all
select 'power( -3, 2.0 )', power( -3, 2.0 ) from RDB$DATABASE
union all
select 'power( -3, -2.0 )', power( -3, -2.0 ) from RDB$DATABASE
union all
select 'power( -3.0, 2 )', power( -3.0, 2 ) from RDB$DATABASE
union all
select 'power( -3.0, 2.0 )', power( -3.0, 2.0 ) from RDB$DATABASE
union all
select 'power( -3.0, -2.0 )', power( -3.0, -2.0 ) from RDB$DATABASE
union all
select 'power( 3.0, -2.0 )', power( 3.0, -2.0 ) from RDB$DATABASE
union all
select 'power( 3.0, 2.0 )', power( 3.0, 2.0 ) from RDB$DATABASE
union all
select 'power( 3.0, 2 )', power( 3.0, 2 ) from RDB$DATABASE
union all
select 'power( 3.0, -2 )', power( 3.0, -2 ) from RDB$DATABASE
 
power( 3, 2 ) 0.000000
power( -3, 2 ) 0.000000
power( 3, -2 ) 0.000000
power( -3, -2 ) 0.000000
power( 3, 2.0 ) 0.000000
power( 3, -2.0 ) 0.000000
power( -3, 2.0 ) 9.000000
power( -3, -2.0 ) 0.111111
power( -3.0, 2 ) 0.000000
power( -3.0, 2.0 ) 9.000000
power( -3.0, -2.0 ) 0.111111
power( 3.0, -2.0 ) 0.000000
power( 3.0, 2.0 ) 0.000000
power( 3.0, 2 ) 0.000000
power( 3.0, -2 ) 0.000000


return wrong values as GR show

Adriano dos Santos Fernandes added a comment - 27/Oct/10 02:42 PM
Just works for me. And I see no way my change to alter the result. It was all about exceptions.


SQL> select 'power( 2, 2 )', power( 2, 2 ) from RDB$DATABASE
CON> union all
CON> select 'power(3, 2)', power(3, 2) from RDB$DATABASE
CON> union all
CON> select 'power(-3.0, 2)', power(-3.0, 2) from RDB$DATABASE
CON> union all
CON> select 'power(3.0, 2.0)', power(3.0, 2.0) from RDB$DATABASE
CON> union all
CON> select 'power(-3, 2.0)', power(-3, 2.0) from RDB$DATABASE
CON> ;


=============== =======================
power( 2, 2 ) 4.000000000000000
power(3, 2) 9.000000000000000
power(-3.0, 2) 9.000000000000000
power(3.0, 2.0) 9.000000000000000
power(-3, 2.0) 9.000000000000000


==========================


SQL> select 'power( 3, 2 )', power( 3, 2 ) from RDB$DATABASE
CON> union all
CON> select 'power( -3, 2 )', power( -3, 2 ) from RDB$DATABASE
CON> union all
CON> select 'power( 3, -2 )', power( 3, -2 ) from RDB$DATABASE
CON> union all
CON> select 'power( -3, -2 )', power( -3, -2 ) from RDB$DATABASE
CON> union all
CON> select 'power( 3, 2.0 )', power( 3, 2.0 ) from RDB$DATABASE
CON> union all
CON> select 'power( 3, -2.0 )', power( 3, -2.0 ) from RDB$DATABASE
CON> union all
CON> select 'power( -3, 2.0 )', power( -3, 2.0 ) from RDB$DATABASE
CON> union all
CON> select 'power( -3, -2.0 )', power( -3, -2.0 ) from RDB$DATABASE
CON> union all
CON> select 'power( -3.0, 2 )', power( -3.0, 2 ) from RDB$DATABASE
CON> union all
CON> select 'power( -3.0, 2.0 )', power( -3.0, 2.0 ) from RDB$DATABASE
CON> union all
CON> select 'power( -3.0, -2.0 )', power( -3.0, -2.0 ) from RDB$DATABASE
CON> union all
CON> select 'power( 3.0, -2.0 )', power( 3.0, -2.0 ) from RDB$DATABASE
CON> union all
CON> select 'power( 3.0, 2.0 )', power( 3.0, 2.0 ) from RDB$DATABASE
CON> union all
CON> select 'power( 3.0, 2 )', power( 3.0, 2 ) from RDB$DATABASE
CON> union all
CON> select 'power( 3.0, -2 )', power( 3.0, -2 ) from RDB$DATABASE;


=================== =======================
power( 3, 2 ) 9.000000000000000
power( -3, 2 ) 9.000000000000000
power( 3, -2 ) 0.1111111111111111
power( -3, -2 ) 0.1111111111111111
power( 3, 2.0 ) 9.000000000000000
power( 3, -2.0 ) 0.1111111111111111
power( -3, 2.0 ) 9.000000000000000
power( -3, -2.0 ) 0.1111111111111111
power( -3.0, 2 ) 9.000000000000000
power( -3.0, 2.0 ) 9.000000000000000
power( -3.0, -2.0 ) 0.1111111111111111
power( 3.0, -2.0 ) 0.1111111111111111
power( 3.0, 2.0 ) 9.000000000000000
power( 3.0, 2 ) 9.000000000000000
power( 3.0, -2 ) 0.1111111111111111

Dzirt added a comment - 27/Oct/10 03:57 PM
In Firebird version 2.1.4.18358? It's impossible...

Adriano dos Santos Fernandes added a comment - 27/Oct/10 05:45 PM
Now I see, I was testing 3.0 and 2.5 only.

It was an error in the 2.1 backport.

I committed a fix and will test later. I'm having problems to build 2.1 in any environments, due to theyr build not supporting new compilers supported in 2.5.

Thanks.

Karol Bieniaszewski added a comment - 29/Oct/10 04:33 AM
I test this under this snapshot 2.1.4.18359 and now all is ok

power( 3, 2 ) 9.000000
power( -3, 2 ) 9.000000
power( 3, -2 ) 0.111111
power( -3, -2 ) 0.111111
power( 3, 2.0 ) 9.000000
power( 3, -2.0 ) 0.111111
power( -3, 2.0 ) 9.000000
power( -3, -2.0 ) 0.111111
power( -3.0, 2 ) 9.000000
power( -3.0, 2.0 ) 9.000000
power( -3.0, -2.0 ) 0.111111
power( 3.0, -2.0 ) 0.111111
power( 3.0, 2.0 ) 9.000000
power( 3.0, 2 ) 9.000000
power( 3.0, -2 ) 0.111111

Philippe Makowski added a comment - 03/May/11 09:05 AM
Q/A test made