Description:
with a Bigint, containing the same number, inconsistent results are obtained;
examples:
length 18
"100000000000000001"=100000000000000001 -> returns true: correct!
"100000000000000010"=100000000000000010 -> returns false: wrong!
"100000000000000100"=100000000000000100 -> returns true: correct!
"100000000000001000"=100000000000000100 -> returns false: correct!
"101000000000000000"=101000000000000000 -> returns true: correct!
"101000000000000000"=101000000000000001 -> returns true: wrong!
length 19
"1000000000000000010"=1000000000000000010 -> returns true: correct!
"1000000000000000100"=1000000000000000100 -> returns false: wrong!
"1000000000000001000"=1000000000000001000 -> returns true: correct!
"1000000000000010000"=1000000000000001000 -> returns false: correct!
"1010000000000000000"=1010000000000000000 -> returns true: correct!
"1010000000000000000"=1010000000000000010 -> returns true: wrong!
How to repeat:
After having created a table and inserted some test values with the following instructions:
Create table cc (string varchar(30), number Bigint(19) UNSIGNED,field3 tinyint(3));
Create table cc (number_s varchar(100), number_b Bigint(19) UNSIGNED,length tinyint(3));
INSERT INTO cc values ("100000000000001", 100000000000001, 15),
("100000000000010", 100000000000010, 15),
("100000000000100", 100000000000100, 15),
("100000000001000", 100000000001000, 15),
("100000000010000", 100000000010000, 15),
("100000000100000", 100000000100000, 15),
("100000001000000", 100000001000000, 15),
("100000010000000", 100000010000000, 15),
("100000100000000", 100000100000000, 15),
("100001000000000", 100001000000000, 15),
("100010000000000", 100010000000000, 15),
("100100000000000", 100100000000000, 15),
("101000000000000", 101000000000000, 15),
("110000000000000", 110000000000000, 15),
("1000000000000001", 1000000000000001, 16),
("1000000000000010", 1000000000000010, 16),
("1000000000000100", 1000000000000100, 16),
("1000000000001000", 1000000000001000, 16),
("1000000000010000", 1000000000010000, 16),
("1000000000100000", 1000000000100000, 16),
("1000000001000000", 1000000001000000, 16),
("1000000010000000", 1000000010000000, 16),
("1000000100000000", 1000000100000000, 16),
("1000001000000000", 1000001000000000, 16),
("1000010000000000", 1000010000000000, 16),
("1000100000000000", 1000100000000000, 16),
("1001000000000000", 1001000000000000, 16),
("1010000000000000", 1010000000000000, 16),
("1100000000000000", 1100000000000000, 16),
("10000000000000001", 10000000000000001, 17),
("10000000000000010", 10000000000000010, 17),
("10000000000000100", 10000000000000100, 17),
("10000000000001000", 10000000000001000, 17),
("10000000000010000", 10000000000010000, 17),
("10000000000100000", 10000000000100000, 17),
("10000000001000000", 10000000001000000, 17),
("10000000010000000", 10000000010000000, 17),
("10000000100000000", 10000000100000000, 17),
("10000001000000000", 10000001000000000, 17),
("10000010000000000", 10000010000000000, 17),
("10000100000000000", 10000100000000000, 17),
("10001000000000000", 10001000000000000, 17),
("10010000000000000", 10010000000000000, 17),
("10100000000000000", 10100000000000000, 17),
("11000000000000000", 11000000000000000, 17),
("100000000000000001", 100000000000000001, 18),
("100000000000000010", 100000000000000010, 18),
("100000000000000100", 100000000000000100, 18),
("100000000000001000", 100000000000000100, 18),
("100000000000001000", 100000000000001000, 18),
("100000000000010000", 100000000000010000, 18),
("100000000000100000", 100000000000100000, 18),
("100000000001000000", 100000000001000000, 18),
("100000000010000000", 100000000010000000, 18),
("100000000100000000", 100000000100000000, 18),
("100000001000000000", 100000001000000000, 18),
("100000010000000000", 100000010000000000, 18),
("100000100000000000", 100000100000000000, 18),
("100001000000000000", 100001000000000000, 18),
("100010000000000000", 100010000000000000, 18),
("100100000000000000", 100100000000000000, 18),
("101000000000000000", 101000000000000000, 18),
("101000000000000000", 101000000000000001, 18),
("110000000000000000", 110000000000000000, 18),
("1000000000000000001", 1000000000000000001, 19),
("1000000000000000010", 1000000000000000010, 19),
("1000000000000000100", 1000000000000000100, 19),
("1000000000000001000", 1000000000000001000, 19),
("1000000000000010000", 1000000000000001000, 19),
("1000000000000010000", 1000000000000010000, 19),
("1000000000000100000", 1000000000000100000, 19),
("1000000000001000000", 1000000000001000000, 19),
("1000000000010000000", 1000000000010000000, 19),
("1000000000100000000", 1000000000100000000, 19),
("1000000001000000000", 1000000001000000000, 19),
("1000000010000000000", 1000000010000000000, 19),
("1000000100000000000", 1000000100000000000, 19),
("1000001000000000000", 1000001000000000000, 19),
("1000010000000000000", 1000010000000000000, 19),
("1000100000000000000", 1000100000000000000, 19),
("1001000000000000000", 1001000000000000000, 19),
("1010000000000000000", 1010000000000000000, 19),
("1010000000000000000", 1010000000000000001, 19),
("1100000000000000000", 1100000000000000000, 19);
executing the following SELECT the inconsistent results are shown:
SELECT number_s, number_b, number_s=number_b, length FROM cc c;
next SELECT will show results as they are expected:
SELECT number_s, number_b, number_s=cast(number_b AS CHAR), length FROM cc c;