# What is the maximum integer value of a Double (In Delphi 7) ?

My question is 2 part:

1). I have a legacy Delphi 7 application that  has a very large file and uses a saved double value to find items  when seeking in the file. It always stores just integer valued in the double ( filepos).
My question is how large can this integer  value be before it is exceeded.  I'd like the a answer in the format 9,999,999,999,999 please.

2). Is there another data type  that occupies the same  number of bytes that could be used instead ( like int64)?
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
0
Oracle dbaCommented:
int64 = 2^64 = 18446744073709551616 positions
why was the double used anyway ?

why not just change the search routine to work directly with int64 ?
0
Author Commented:
It is quite a complex legacy system and the double value is used throughout and in a database index.   I need to know how large can this integer part of the double can be before it is exceeded.  (in the format 9,999,999,999,999 please). This way I can see if I need to change it.  Thanks
0
Oracle dbaCommented:
from the help:
Double      5.0 x 10^-324 .. 1.7 x 10^308       15-16      8

this means you 15-16 significant digits
this means a value up to 999,999,999,999,999 is accurate
otherwise it's not that accurate
you can best test this accuracy with

var aNumber: string;
begin
aNumber := '999999999999999';
NewNumber := FloatToStr(StrToFloat(aNumber));
ShowMessage(Format('%s -> %s', [aNumber, NewNumber]));
end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
quote from delphi help:
The double keyword designates a 64-bit floating-point number.

The table below gives the ranges and storage formats for the fundamental real types.
Type      Range      Significant digits      Size in bytes
Double      5.0 x 10^-324 .. 1.7 x 10^308       15-16      8

Int64      -2^63..2^63-1      signed 64-bit

which means a double can store a positive number with about 15 to 16 digits.
an int64 has a max value of 9223372036854775807 (19 digits)
0
Oracle dbaCommented:
in a database ?
what type ? in some database you can give precision up to 38 digits

from oracle:

NUMBER Datatype

The NUMBER datatype stores zero, positive, and negative fixed and floating-point numbers with magnitudes between 1.0 x 10-130 and 9.9...9 x 10125 (38 nines followed by 88 zeroes) with 38 digits of precision. If you specify an arithmetic expression whose value has a magnitude greater than or equal to 1.0 x 10126, then Oracle returns an error.

Specify a fixed-point number using the following form:

NUMBER(p,s)

where:

* p is the precision, or the total number of digits. Oracle guarantees the portability of numbers with precision ranging from 1 to 38.
* s is the scale, or the number of digits to the right of the decimal point. The scale can range from -84 to 127.

0
Commented:
this happens when you write the stuff down and answer the phone before posting :D so sorry to repeat what was alredy said. ignore me :)
0
Author Commented:
Thanks Geert  '999,999,999,999,999' is the max before it displays as an exponential number.  So, if the double stored, is basically an integer  we can store  up to 999,999,999,999,999.   The bit I want to clarify ( just so I understand) is that  each additional decimal place used will reduce the integer value by a factor of 10.

For example,   using a  number of   123.45 , the maximum integer value would be   '9,999,999,999,999'  which allows for an additional 2 decimal places.
Is this correct?

Thanks

0
Oracle dbaCommented:
in short,
yup
0
Oracle dbaCommented:
>>ignore me :)
allways ?
0
Author Commented:
Hi Geert,   It is not a formal database as such. It uses seek to access data
0
Author Commented:
Thanks everybody.
0
Author Commented:
Thanks for your help
0
Commented:
>> allways ?

lol. just that time :P

PS:
>>  '999,999,999,999,999' is the max before it displays as an exponential number.

the fact that it DISPLAYS as exponential has nothing to do with the number being or not being integer. the significant digits are 15 to 16. '999,999,999,999,999' is 15 digits. so you still have room. increment that number by one and you will see, it's still integer ;)
0
Author Commented:
Thanks ciuly.
0
Commented:
np.
don't understand that by "if you add another 9 after the initial 15 9's, you still have an integer number". I said increment. that is add 1 to it. the maximum integer number is somewhere around 17xxxx (16 digits). googleing reveals
1797693134862315.7 if I am correct with moving the dot :)
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.