http://www.delphibasics.co

Solved

Posted on 2008-11-04

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)?

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)?

16 Comments

Check link below:

http://www.delphibasics.co.uk/Article.asp?Name=DataTypes

http://www.delphibasics.co

why was the double used anyway ?

why not just change the search routine to work directly with int64 ?

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(aNum

ShowMessage(Format('%s -> %s', [aNumber, NewNumber]));

end;

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)

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.

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

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 ;)

The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**18** Experts available now in Live!