AnyhowStep/tsql

Document differences in CAST(... AS BIGINT)

Opened this issue · 1 comments

SELECT 
  CAST(1.1 AS BIGINT),
  CAST(1.5 AS BIGINT),
  CAST(1.7 AS BIGINT),
  CAST(-1.1 AS BIGINT),
  CAST(-1.5 AS BIGINT),
  CAST(-1.7 AS BIGINT);

PostgreSQL,

int8 int8 int8 int8 int8 int8
1 2 2 -1 -2 -2

SQLite,

CAST(1.1 AS BIGINT) CAST(1.5 AS BIGINT) CAST(1.7 AS BIGINT) CAST(-1.1 AS BIGINT) CAST(-1.5 AS BIGINT) CAST(-1.7 AS BIGINT)
1 1 1 -1 -1 -1

MySQL,

CAST(1.1 AS SIGNED) CAST(1.5 AS SIGNED) CAST(1.7 AS SIGNED) CAST(-1.1 AS SIGNED) CAST(-1.5 AS SIGNED) CAST(-1.7 AS SIGNED)
1 2 2 -1 -2 -2

SQLite truncates.

MySQL and PostgreSQL round.