Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3045
  • Last Modified:

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)?
0
SarusSystems
Asked:
SarusSystems
  • 6
  • 5
  • 4
  • +1
1 Solution
 
kerwinsiyCommented:
0
 
Geert GruwezOracle 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
 
SarusSystemsAuthor 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Geert GruwezOracle 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
 
2266180Commented:
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
 
Geert GruwezOracle 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
 
2266180Commented:
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
 
SarusSystemsAuthor 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
 
Geert GruwezOracle dbaCommented:
in short,
yup
0
 
Geert GruwezOracle dbaCommented:
>>ignore me :)
allways ?
0
 
SarusSystemsAuthor Commented:
Hi Geert,   It is not a formal database as such. It uses seek to access data
0
 
SarusSystemsAuthor Commented:
Thanks everybody.
0
 
SarusSystemsAuthor Commented:
Thanks for your help
0
 
2266180Commented:
>> 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
 
SarusSystemsAuthor Commented:
Thanks ciuly.
0
 
2266180Commented:
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 6
  • 5
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now