Why can I split Single by Variant in Delphi and what is it for?

I was surprised to see that floating point values ​​can be divided into a variant in Delphi. A simple example of what can be done:

var
  v: Variant;
begin
  v := 2.3;
  Tag := 5.1 div v; // 2
  Tag := 5.1 mod v; // 1
  Tag := 5.1 div 2; // [dcc32 Error] E2015 Operator not applicable to this operand type
  Tag := 5.1 mod 2; // [dcc32 Error] E2015 Operator not applicable to this operand type
end;

It seems that Delphi completes the left side and the right side before performing the div/ operation mod.

I would expect code to appear during compilation in all 4 lines, as I understand that div / mod are not applicable to floating point values ​​no matter what. Clearly, this is not so.

Why can I share Single by Variant in Delphi and what is it for?

+4
source share
1 answer

Of the expression options :

, .

, .

, div/mod.

.. ?

OLE.

+7

Source: https://habr.com/ru/post/1672892/


All Articles