Int64 is insufficient for your needs as it ranges from
-9223372036854775808 .. 9223372036854775807
i.e. max of 19 digits, you need 23
Regards
Pierre
Main Topics
Browse All TopicsHi,
I need to store a 23 digit number in a 'numeric' variable. e.g. 20041010050500013402606
At the moment i have the string stored in a 'String' variable, However i need to convert it to a numeric type variable in order to apply a modulus 97.
I have tried with an integer variable using StrToInt(), I have tried with an Int64 variable using StrToInt64() but unfortunately it always come back with a compilation error "Integer constant too long". If i continue the execution of the program the the system throws an error message that reads "20041010050500013402606 is not a valid integer value"
I am currently using Delphi 6 enterprise edition.
I appreciate any help you can provide me with on this matter.
Cheers.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
for a string library on big integers, see my post with the code from here: http://www.experts-exchang
Hi, I think this is what you are looking for
http://delphiforfun.org/Pr
Operations supported are: Assign, Add, Subtract, Multiply, Divide, Modulo, Compare, Factorial, and ConvertToDecimalString.
It will support integers far larger than your needs
David
By no means it's efficient.
But is it worth to install those libraries for a few lines of code?
function Modulo97(s: string): integer;
var
val: integer;
i: integer;
begin
val := 0;
if Length(s) > 0 then
begin
val := Ord(s[1])-Ord('0');
i := 2;
while i <= Length(s) do
begin
val := 10*val+Ord(s[i])-Ord('0');
val := val mod 97;
Inc(i);
end;
end;
Result := val;
end;
A little bit simpler version.
I've assumed it's positive and I don't check for valid chars.
function Modulo97(s: string): integer;
var
val: integer;
i: integer;
begin
val := 0;
if Length(s) > 0 then
begin
i := 1;
while i <= Length(s) do
begin
val := 10*val+Ord(s[i])-Ord('0');
val := val mod 97;
Inc(i);
end;
end;
Result := val;
end;
Business Accounts
Answer for Membership
by: mokulePosted on 2006-04-25 at 08:23:33ID: 16535173
do the calculation on a string data