• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 548
  • Last Modified:

converting string to integer

How do i convert a string to integer which is to large and exceed 2147483647 in delphi 3 ?

Thank you.      
0
n_chai
Asked:
n_chai
1 Solution
 
dwwangCommented:
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
 
MadshiCommented:
If you've Delphi4 you can use StrToInt64 and you'll get an 8 byte integer (int64) as a result.

Regards, Madshi.
0
 
binkzzCommented:
Otherwise just StrToInt(); will do

Bink
0
Technology Partners: 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!

 
StevenBCommented:
 ... or StrToIntDef() and avoid having to handle your own exceptions.
0
 
philipleighsCommented:
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
 
rickpetCommented:
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
 
slautinCommented:
You must use 8 or more bytes for storing lage values.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now