Solved

converting string to integer

Posted on 1998-12-16
7
538 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

827 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