Skip to content

The sign of the number changes when bigint overflows #8959

@Noremos

Description

@Noremos

String-to-Bigint cast works well

select cast('9.223372036854775e18' as bigint) from rdb$database; -- OK
                 CAST 
===================== 
  9223372036854775000 

select cast('9.223372036854775e19' as bigint) from rdb$database; -- OK
                 CAST 
===================== 
Statement failed, SQLSTATE = 22003
arithmetic exception, numeric overflow, or string truncation
-numeric value is out of range

But Double-to-BigInt cast changes the sign

SQL> select cast(9.223372036854775e18 as bigint) from rdb$database;  - Sign error

                 CAST 
===================== 
 -9223372036854775808 

SQL> select cast(9.223372036854775e19 as bigint) from rdb$database;  -- OK

                 CAST 
===================== 
Statement failed, SQLSTATE = 22003
arithmetic exception, numeric overflow, or string truncation
-numeric value is out of range

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions