Solved

Large variables?

Posted on 2000-03-23
11
166 Views
Last Modified: 2010-04-04
Hi everybody.

I'm making a "perfect number finder", to find certain mathematical numbers. But the results are too big to fit into a variable. I have very large numbers. There must be someway to store these, look at the calculator that comes with windows, it handles 36 places, and after that it goes over to exponentials. I want my program to works just like that.

How can this be done?

--johan
0
Comment
Question by:sageryd
[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
  • 3
  • 2
  • 2
  • +3
11 Comments
 
LVL 2

Expert Comment

by:Serega
ID: 2652276
Standard types can hold:
Extended      up to  1.1 x 10^4932      
Comp up to 2^63 - 1
If you want to hold bigger numbers, I think there is no simple way to do that. You should to write your own procedures to work with numbers.
0
 
LVL 12

Expert Comment

by:Faruk Onder Yerli
ID: 2652281
The standart Delphi functions allow to 19 digits with double or Int64. If you want to more up digits you must write.
0
 

Expert Comment

by:frangers99
ID: 2652289
Sageryd,

The largest integer type you can get is an int64 which uses 8 bytes. A normal integer uses 4 bytes and has a range of –2147483648 to 214748364. An int64 should be able to handle most values.
An int64 has the range –2^63..2^63–1.
To specify an int64 instead of using

var
number : integer;

use

var
number : int64;

A real number is a decimal point number. An 'comp' real has the range -2^63+1 to 2^63 –1. Where as the usual real has the range much lower. For more help refer to the online help. Lookup int64, and floating-point numbers.

Hope that helps.      

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!

 

Expert Comment

by:frangers99
ID: 2652291
sorry as i was typing the response you added that comment. I am pretty sure you are right, you need some code. I advise you look on http://www.delphipages.com under mathematical components, i am sure there will be one that does what you want.

Andrew
0
 

Expert Comment

by:crazydragonx
ID: 2652507
Try to make one component from array of char, and then parse it to numeric.

Ex.
A : Array[1..100] Of Char;
B : Array[1..100] Of Char;
Result : Array[1..100] Of Char;

....
A =      123456789123456787
B =      972482384837283283
---------------------------- +
Result = .....parse char by char

The logic is like that, i ever made that but in C++.

Hope this can help !
0
 

Expert Comment

by:crazydragonx
ID: 2652539
Or If you think using array of char is to slow, than you can use array of Integer or longInt
Like :
A : Array[1..20] Of Integer;

So you can assume that first array is first 5 digits.

A[1] --> digit 1 - 5
A[2] --> digit 6 - 10
....
....
....
A[20] --> digit 96 - 100

Hope this can help you...




0
 
LVL 1

Author Comment

by:sageryd
ID: 2652600
Ok, good solutions. But how can I easily assign my calculated number to the constructed variable(s)?

--johan
0
 
LVL 2

Expert Comment

by:Serega
ID: 2652659
How you represent calculated numbers in memory ?
May be you only need procedure of displaying them as string ?
0
 
LVL 15

Accepted Solution

by:
simonet earned 200 total points
ID: 2652882
Here you go:

Fast Gigantic Integers (GINT):

http://ace.ulyssis.student.kuleuven.ac.be/~triade/GInt/gint.html 

If your work is RSA-related, this site will also be interesting:

http://ace.ulyssis.student.kuleuven.ac.be/~triade/GInt/ 

Both sites will teach you how to work with Gigantic integers, which are far bigger than INT64 or TLargeInteger. The first site also features a free (src. included) class that encapsulates gigantic integers along with tips and demos on using it. Very nice!

Yours,

Alex

0
 
LVL 1

Author Comment

by:sageryd
ID: 2653401
Well....thanks Alex, but I'm not sure on how it works...can you give an example?
0
 
LVL 1

Author Comment

by:sageryd
ID: 2697490
Sorry it took so long, I've been working on another project for some time, the numberfinder has low priority. Thanx for all your help!

--johan
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

615 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