1 (edited by Step-in 2024-01-16 14:05:34)

Topic: [SOLVED]A new problem with StrToInt64

In the program, I write the code for conversion and verification of the IBAN of the account. In it, I operate with values of 31 characters. When executing StrToInt64 (1234567890123456789012345678901) gives an error: "1234567890123456789012345678901" is not valid integer value.

I read many forums and tips. Everywhere it says that it should work. What can be done about it?

Re: [SOLVED]A new problem with StrToInt64

Step-in wrote:

In the program, I write the code for conversion and verification of the IBAN of the account. In it, I operate with values of 31 characters. When executing StrToInt64 (1234567890123456789012345678901) gives an error: "1234567890123456789012345678901" is not valid integer value.

I read many forums and tips. Everywhere it says that it should work. What can be done about it?

var
  A, B, C, D, E, F : Int64;

begin
  A := 32;
  B := StrToInt64('100');    // строка '100' преобразуется в целочисленное 100
  C := StrToInt64('  -12');  // Начальные пробелы игнорируются
  D := StrToInt64('$1E');    // Шестнадцатеричные значения начинаются с '$'
  E := StrToInt64('-0x1E');  // ... или с '0x'

переменная должна быть - Int64
значение должно быть в скобках String; - text
 
the variable must be Int64
the value must be in brackets String; - text

Re: [SOLVED]A new problem with StrToInt64

I don’t know what’s on the forums, but in the DELPHI Basic Tutorial it says:

  Min int64 value = -9223372036854775808
  Max int64 value = 9223372036854775807

http://www.delphibasics.co.uk/RTL.php?Name=Int64

Re: [SOLVED]A new problem with StrToInt64

Please see an example...frmAddPayee_Edit3_OnExit

Post's attachments

Attachment icon PaymentsRegister m.zip 360.38 kb, 35 downloads since 2024-01-15 

Re: [SOLVED]A new problem with StrToInt64

sparrow wrote:

I don’t know what’s on the forums, but in the DELPHI Basic Tutorial it says:

  Min int64 value = -9223372036854775808
  Max int64 value = 9223372036854775807

http://www.delphibasics.co.uk/RTL.php?Name=Int64

Oh, only 19 characters up to 9223372036854775807. What can be done in my case? Will MVD not be able to handle this situation?

Re: [SOLVED]A new problem with StrToInt64

Step-in wrote:
sparrow wrote:

I don’t know what’s on the forums, but in the DELPHI Basic Tutorial it says:

  Min int64 value = -9223372036854775808
  Max int64 value = 9223372036854775807

http://www.delphibasics.co.uk/RTL.php?Name=Int64

Oh, only 19 characters up to 9223372036854775807. What can be done in my case? Will MVD not be able to handle this situation?

Unless you really need some sort of calculation or anything very specific to be done with your very long strings, the best would be to use a text based field and use it as a string. The limitations are the same for SQLite than for Delphi.

Re: [SOLVED]A new problem with StrToInt64

Step-in wrote:
sparrow wrote:

I don’t know what’s on the forums, but in the DELPHI Basic Tutorial it says:

  Min int64 value = -9223372036854775808
  Max int64 value = 9223372036854775807

http://www.delphibasics.co.uk/RTL.php?Name=Int64

Oh, only 19 characters up to 9223372036854775807. What can be done in my case? Will MVD not be able to handle this situation?


Why do you need to convert all the characters into numbers and what type of IBAN verification do you want to do?

8 (edited by pavlenko.vladimir.v 2024-01-15 17:47:56)

Re: [SOLVED]A new problem with StrToInt64

var
    IBAN, IBANText: string;
    IBANverify: Int64;
begin
    IBAN := frmAddPayee.Edit3.Text;
    IBANText := Copy(IBAN,3,25)+ '1011'+ Copy(IBAN,1,2);
    IBANverify := StrToInt64('IBANNum');
    if IBANverify = 0 then
    begin
        showmessage('Error');
    end
    else
    begin
        showmessage('Good');
    end;

вообще не понимаю:
Зачем капировать символы, я не вижу продолжения.
Зачем проверять IBANverify  если его значение будет всегда одинаково.
 
I don't understand at all:
Why copy the characters, I don’t see a continuation.
Why check IBANverify if its value will always be the same.
 
 
 
может Вы хотели сделать так
maybe you wanted to do this

IBANverify := StrToInt64(IBANText);

Re: [SOLVED]A new problem with StrToInt64

1. Your input mask does not match the IBAN input format. The first two characters must be letters.
2. Checksum verification does not require converting the entire string to a number.
You can read all the information on IBAN, verification and how to get around the problem of large numbers at the link
https://en.wikipedia.org/wiki/Internati … unt_Number

Re: [SOLVED]A new problem with StrToInt64

pavlenko.vladimir.v wrote:

I don't understand at all:
Why copy the characters, I don’t see a continuation.
Why check IBANverify if its value will always be the same.

I'm checking my account against the checksum. Attached the full calculation.

sparrow wrote:

Why do you need to convert all the characters into numbers and what type of IBAN verification do you want to do?

It's all about the formula for checking the correctness of entering the account relative to the control amount. It is necessary to operate with all symbols (31).

Post's attachments

Attachment icon PaymentsRegister m_1.zip 360.45 kb, 30 downloads since 2024-01-16 

11 (edited by sparrow 2024-01-16 09:36:10)

Re: [SOLVED]A new problem with StrToInt64

... wrote:

It's all about the formula for checking the correctness of entering the account relative to the control amount. It is necessary to operate with all symbols (31).


I will repeat to you once again that checking in DELPHI and other languages that cannot operate with very large numbers (in our case up to 31 digits) does not require converting the entire number and is performed on a string of characters.


Your code in DELPHI will not work.
How to do this in DELPHI is described in the article at the link I gave you above. In addition, this non-working code also contains a calculation error.

12 (edited by Step-in 2024-01-16 14:04:26)

Re: [SOLVED]A new problem with StrToInt64

sparrow wrote:
... wrote:

It's all about the formula for checking the correctness of entering the account relative to the control amount. It is necessary to operate with all symbols (31).


I will repeat to you once again that checking in DELPHI and other languages that cannot operate with very large numbers (in our case up to 31 digits) does not require converting the entire number and is performed on a string of characters.


Your code in DELPHI will not work.
How to do this in DELPHI is described in the article at the link I gave you above. In addition, this non-working code also contains a calculation error.

Infinite gratitude for help and advice. Thank you for pointing out my inattention.
I knew about the limitation of variables, I just gave as an example how I perform mathematical operations.
Thank you very much.

The finished code is below.

function CalculateIBANMod97(const IBAN: string): Integer;
var
  D, N: string;
  Index, Len: Integer;
begin
  D := Copy(IBAN, 3, Length(IBAN) - 2) + '1011'+ Copy(IBAN, 1, 2);
  N := Copy(D, 1, 9);

  for Index := 10 to Length(D) do
  begin
    N := IntToStr(StrToInt(N) mod 97) + Copy(D, Index, 1);
  end;

  Result := StrToInt(N) mod 97;
end;

procedure frmAddPayee_Edit3_OnExit (Sender: TObject);
var
  IBAN: string;
  Mod97Result: Integer;
begin
  IBAN := frmAddPayee.Edit3.Text;
  Mod97Result := CalculateIBANMod97(IBAN);
  ShowMessage(IntToStr(Mod97Result));
end;