Хранилище данных Azure - исправление значения bigint в столбце типа данных Float

<input type="button"> - это просто кнопка и ничего не сделает сама по себе. <input type="submit">, когда внутри элемента формы, будет отправлять форму при нажатии.

Еще одна полезная специальная кнопка - <input type="reset">, которая очистит форму.

-1
задан Andrey Nikolov 17 January 2019 в 18:07
поделиться

1 ответ

Давайте начнем с диапазона BigInt : от -2 ^ 63 (-9,223,372,036,854,775,808) до 2 ^ 63-1 (9,223,372,036,854,775,807). Это примерно ± 9E + 18, поэтому -4,66606E + 22 маловероятно BigInt.

Перейдем к сравнению значений различных типов данных:

declare @Foo as BigInt = 8765432109876543210;
declare @FloatFoo as Float(24) = @Foo, @DoubleFoo as Float(53) = @Foo;

-- According to the rules for data type preedence a BigInt value will be converted to a Float
--   when the two data types are compared. Hence all of the values are "equal".
select @Foo as Foo,
  @FloatFoo as FloatFoo, case when @Foo = @FloatFoo then 1 else 0 end as FloatMatch,
  @DoubleFoo as DoubleFoo, case when @Foo = @DoubleFoo then 1 else 0 end as DoubleMatch;

-- Since a Float(53) has a precision of 15 digits that means some precision will be lost.
set @Foo += 1; -- Bump the BigInt value, but leave the Floats unchanged.
-- And ... the values are all still "equal"!
select @Foo as Foo,
  @FloatFoo as FloatFoo, case when @Foo = @FloatFoo then 1 else 0 end as FloatMatch,
  @DoubleFoo as DoubleFoo, case when @Foo = @DoubleFoo then 1 else 0 end as DoubleMatch;

-- Once more, with feeling.
set @Foo += 1000; -- A bigger bump makes the Float(53) value different, but not the Float(24).
select @Foo as Foo,
  @FloatFoo as FloatFoo, case when @Foo = @FloatFoo then 1 else 0 end as FloatMatch,
  @DoubleFoo as DoubleFoo, case when @Foo = @DoubleFoo then 1 else 0 end as DoubleMatch;

Ссылки: Приоритет типа данных , Float .

Резюме: «Имеются неверные данные со значением bigint. Значение - -4.66606E+22». Это действительно плохие данные. А сравнение значений BigInt и Float является неточной деятельностью, которая может привести к разочарованию.

0
ответ дан HABO 17 January 2019 в 18:07
поделиться
Другие вопросы по тегам:

Похожие вопросы: