Solved

converting string to integer

Posted on 1998-12-16
7
533 Views
Last Modified: 2010-04-04
How do i convert a string to integer which is to large and exceed 2147483647 in delphi 3 ?

Thank you.      
0
Comment
Question by:n_chai
7 Comments
 
LVL 4

Expert Comment

by:dwwang
ID: 1351451
Why not convert it to double/extended?

You know, even you can convert it to an "integer", it will result in no use because it cannot participate any calculation with other integers due to exceeding the limit of this type.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1351452
If you've Delphi4 you can use StrToInt64 and you'll get an 8 byte integer (int64) as a result.

Regards, Madshi.
0
 
LVL 4

Expert Comment

by:binkzz
ID: 1351453
Otherwise just StrToInt(); will do

Bink
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Expert Comment

by:StevenB
ID: 1351454
 ... or StrToIntDef() and avoid having to handle your own exceptions.
0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1351455
4 byte signed integers (D3 Integer type) can't represent numbers greater than 2^31-1, that's why StrToInt fails.
There is no 4 byte unsigned type in D3, it could have been Cardinal or DWORD, but they are both declared as Integer (I think). At least then you could have got to 2^32-1.

As dwwang says, use Extended remembering that they don't represent integers very well.

What's the nature of your app any, and why the big numbers?
0
 
LVL 3

Accepted Solution

by:
rickpet earned 30 total points
ID: 1351456
You should use a comp type...

In Delphi 3 this is 64bit integer though internally it is a Floating Type.

from Delphi 3 help.
The Comp (computational) type is a 64-bit integer that holds integral values from
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (-263 to 263-1).

0
 
LVL 1

Expert Comment

by:slautin
ID: 1351457
You must use 8 or more bytes for storing lage values.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now