E
E
Evgeny Ivanov2017-05-29 12:05:56
Delphi
Evgeny Ivanov, 2017-05-29 12:05:56

How to write a double value to an array of type variant?

The array FINAL_ARRAY of type Variant contains various information. These are text and integers.

FINAL_ARRAY : array of array [1..5] of Variant;
.....
FINAL_ARRAY[1,1]:='Текст';
//Далее все заполним нулями
for i:=2 to 5 do
begin
for j:=1 to 9 do
begin
FINAL_ARRAY[j,i]:=0;
end;
end;

I need to write to an array (and then display) a fractional number, rounded to tenths.
For unknown reasons, the number remains an integer. But the array is Variant.
Code Example
percent:float; //процент
current_float:float; //просто дробное число
...
percent:=FINAL_ARRAY[7,4] div 100; //Деление с остатком. результат помещаем в percent типа float 
for i:=2 to 6 do
begin
current_float:=RoundTo(FINAL_ARRAY[i,4] div percent, -1); //получили дробное число и округлили до десятых
FINAL_ARRAY[i,5]:=current_float; //Тут целое число?. Но деление было с остатком. Почему не дробное?
end;

How to write a double value to an array of type variant?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kalapanga, 2017-05-29
@logpol32

And why suddenly div is a division with a remainder? Quite the opposite.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question