Home > Back-end >  How to turn the string into the extended in Delphi? Urgent please... Strtofloat in?
How to turn the string into the extended in Delphi? Urgent please... Strtofloat in?

Time:09-20

I now have to deal with the figures in this form: 9.062705115038622 e-4 or 0.0018839088514177576 because it USES double not, more than double can store is extended, right? Now I want to make more than digital string into extended type of existence in the array, but strtofloat interception accuracy is changed, for example: 0.0022783474240102275 use strtofloat is 0.002278347424 after only the first 12, how to do?
I also tried with val, the result is still the same can only be intercepted before 12 string, what shall I do?????? Please give a great god help me!!!!!!!!!!!!!!!!!!!!!

CodePudding user response:

Still don't go directly to the string stored in the array is not the same?

CodePudding user response:

Delphi32 is no problem, extended in delphi64=double, so alone is less than 19/20 of a precision, but the double 15/16, not only 12,
Test:
Var
S: a string;
X: extended;
The begin
S:='0.0022783474240102275';
X:=StrToFloat (s);
Writeln (x: 0:19);
end;

CodePudding user response:

Out into the array, and then the number or you

 var 
S: a string;
Dd: Extended;
Str: string;
VD: array [1.. 5] of Extended;
The begin
S:='0.0022783474240102275';
Dd:=StrToFloat (s);
VD [2] :=dd;
Str:=FormatFloat (' 0.000000000000000000000000000000 ', vD [2]).
end;

CodePudding user response:

Can't you turn strtofloat directly

CodePudding user response:

refer to the second floor DelphiGuy response:
there is no question of delphi32, extended in delphi64=double, so alone is less than 19/20 of a precision, but the double 15/16, not only 12,
Test:
Var
S: a string;
X: extended;
The begin
S:='0.0022783474240102275';
X:=StrToFloat (s);
Writeln (x: 0:19);
end;

Thank you for your reply, I may not understand, I now have to deal with the number of characters in a notepad, 9.062705115038622 e-4 or 0.0018839088514177576 this kind of form, there are e, can I put out in the array, but I have to to such a small number multiplied by a fraction (results will change small), and then save it, so that multiple results will again after an extremely small number (similar to this form: 9.062705115038622 e-4 or 0.0018839088514177576) is obtained by the largest number, I can decrease the precision to ensure the calculation speed, now the problem is that the number of e, not directly capture before XXX, is a Java to the number of generated, on the Delphi is bad to deal with, I also will they take on the decimal sum sorting again again, have any good ideas? Thank you very much!

CodePudding user response:

reference hongss reply: 3/f
into an array, and then taken out or you this number

 var 
S: a string;
Dd: Extended;
Str: string;
VD: array [1.. 5] of Extended;
The begin
S:='0.0022783474240102275';
Dd:=StrToFloat (s);
VD [2] :=dd;
Str:=FormatFloat (' 0.000000000000000000000000000000 ', vD [2]).
end;

Thank you for your reply, I may not understand, I now have to deal with the number of characters in a notepad, 9.062705115038622 e-4 or 0.0018839088514177576 this kind of form, there are e, can I put out in the array, but I have to to such a small number multiplied by a fraction (results will change small), and then save it, so that multiple results will again after an extremely small number (similar to this form: 9.062705115038622 e-4 or 0.0018839088514177576) is obtained by the largest number, I can decrease the precision to ensure the calculation speed, now the problem is that the number of e, not directly capture before XXX, is a Java to the number of generated, on the Delphi is bad to deal with, I also will they take on the decimal sum sorting again again, have any good ideas? Thank you very much!

CodePudding user response:

A, Extended long floating point number
3.6 x 10 ^ - the range of 4951-1.1 x 10 ^ 4932
The accuracy of the 19.. 20

Second, you will be data into Extended, to loss of accuracy
Such as 0.0018839088514177576
Stored in the Extended the actual value is 0.00188390885141776 (rounded more than 19)

Three, your problem, involves the high precision of calculation
It is recommended to use the following an array data
A: an array of byte [- 100.. 100].
- 110..
0 saved before the decimal point data1.. 100 decimal places for storage data

In this way, and comparison operations can addition, subtraction, multiplication, and division, is the need to transform, (mainly bitwise operations)

CodePudding user response:

reference 5 floor whiskey94945 reply:
Quote: refer to the second floor DelphiGuy response:

Delphi32 is no problem, extended in delphi64=double, so alone is less than 19/20 of a precision, but the double 15/16, not only 12,
Test:
Var
S: a string;
X: extended;
The begin
S:='0.0022783474240102275';
X:=StrToFloat (s);
Writeln (x: 0:19);
end;

Thank you for your reply, I may not understand, I now have to deal with the number of characters in a notepad, 9.062705115038622 e-4 or 0.0018839088514177576 this kind of form, there are e, can I put out in the array, but I have to to such a small number multiplied by a fraction (results will change small), and then save it, so that multiple results will again after an extremely small number (similar to this form: 9.062705115038622 e-4 or 0.0018839088514177576) is obtained by the largest number, I can decrease the precision to ensure the calculation speed, now the problem is that the number of e, not directly capture before XXX, is a Java to the number of generated, on the Delphi is bad to deal with, I also will they take on the decimal sum sorting again again, have any good ideas? Thank you very much!


Rectified haven't solve? This problem is a matter...
Var
X: extended;
The begin
X:=9.062705115038622 e-4.//: x=StrToFloat (' 9.062705115038622 e-4);
Writeln (FormatFloat (' 0. # # # # # # # # # # # # # # # # # # # ', x));
end;
  • Related