?
Solved

converting string to integer

Posted on 1998-12-16
7
Medium Priority
?
544 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 60 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month10 days, 4 hours left to enroll

762 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