 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Andrue Cope [TeamB] Guest
|
Posted: Mon Dec 12, 2005 11:37 am Post subject: Integral value > unsigned _int64? |
|
|
I have a potential need for an integral value with more than 64 bits.
Has anything been mentioned in the standard yet or am I looking at
rolling my own/using a 3rd party library?
For the time being it won't be an issue but one or two of my
calculations that risked 32-bit overflow now risk 64-bit overflow. At
present it's not very likely a file would grow to that size but I like
to plan advance :)
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
Alan Bellingham Guest
|
Posted: Mon Dec 12, 2005 2:02 pm Post subject: Re: Integral value > unsigned _int64? |
|
|
"Andrue Cope [TeamB]" <no.spam (AT) not (DOT) a.valid.address> wrote:
| Quote: | I have a potential need for an integral value with more than 64 bits.
Has anything been mentioned in the standard yet or am I looking at
rolling my own/using a 3rd party library?
|
Sounds like a job for a BigInt class. At least until you're on a
platform with support for ... 128-bit integers.
| Quote: | For the time being it won't be an issue but one or two of my
calculations that risked 32-bit overflow now risk 64-bit overflow. At
present it's not very likely a file would grow to that size but I like
to plan advance
|
I expect most file systems to start having problems if file sizes exceed
64 bits. Or even 63 bits (allowing seek from end).
That's millions of terabytes. Allowing 1TB as a sensible maximum right
now, then you have 23 doublings of capacity to worry about first.
Moore's law will give you an approximate time before you can expect that
to occur, but frankly, it's probably easier to check your currently
supported file systems and see if any of them support greater than
64-bit addressing yet.
Alan Bellingham
--
ACCU Conference 2006 - 19-22 April, Randolph Hotel, Oxford, UK
|
|
| Back to top |
|
 |
Andrue Cope [TeamB] Guest
|
Posted: Mon Dec 12, 2005 3:02 pm Post subject: Re: Integral value > unsigned _int64? |
|
|
Alan Bellingham wrote:
| Quote: | it's probably easier to check your currently
supported file systems and see if any of them support greater than
64-bit addressing yet.
|
Not at the moment. In fact those that could often don't. Even Microsoft
are leary about NTFS:
http://www.microsoft.com/whdc/device/storage/LUN_SP1.mspx
But this is why I'm not too desperate and was little more than curious.
"However, NTFS reduces this, because it supports a 32-bit cluster
number "
...that intrigues me because cluster numbers in NTFS are 64-bit. I can
only assume this is a coding limitation rather than a file system
limitation.
It's just that when you are multiplying a number of clusters (QWORD) by
the cluster size in bytes (DWORD) a wise programmer ponders the issue
of 64-bit overflow. You could argue that it'll be at least a decade
before it becomes a problem but then I've been working on this code
base for 13 years already :)
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
Bob Gonder Guest
|
Posted: Mon Dec 12, 2005 4:40 pm Post subject: Re: Integral value > unsigned _int64? |
|
|
Andrue Cope [TeamB] wrote:
| Quote: | It's just that when you are multiplying a number of clusters (QWORD) by
the cluster size in bytes (DWORD) a wise programmer ponders the issue
of 64-bit overflow. You could argue that it'll be at least a decade
before it becomes a problem but then I've been working on this code
base for 13 years already
|
I think the more usual solution is to first divide by K, M G or T so
you get a reasonable number of digits when you multiply..
ie. scale first, then multiply.
That works for displays, but if you need it internal, then don't
multiply in the first place. Just use the two values for looping.
|
|
| Back to top |
|
 |
Andrue Cope [TeamB] Guest
|
Posted: Mon Dec 12, 2005 4:46 pm Post subject: Re: Integral value > unsigned _int64? |
|
|
Bob Gonder wrote:
| Quote: | That works for displays, but if you need it internal, then don't
multiply in the first place. Just use the two values for looping.
|
Generally we do but this is when our code needs to calculate the size
of a file. BytesInCluster*NumberOfClustersInChain.
For now I've put guards in. It was easy enough, just upgrade the
existing guards. So far the widening has gone quite well but I haven't
produced a compiling library yet. I think that'll be sometime later
this week, lol.
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
Bob Gonder Guest
|
Posted: Mon Dec 12, 2005 5:08 pm Post subject: Re: Integral value > unsigned _int64? |
|
|
Andrue Cope [TeamB] wrote:
| Quote: | That works for displays, but if you need it internal, then don't
multiply in the first place. Just use the two values for looping.
Generally we do but this is when our code needs to calculate the size
of a file. BytesInCluster*NumberOfClustersInChain.
|
Well, yes, but to what purpose?
What are you going to do with that size?
I can only think of 3 things.
1) Display it (20 digit file size is unintelligable)
2) Allocate memory buffer for it (yeah, right)
3) Process the file (can be broken down into cluster ops)
OTOH, if you are dead set on having really big numbers, then as Alan
mentioned, BigInt library would be the way to go.
I would think that if all your code used such a library, then as
larger ALUs come on market, the library would refactor the now
intrinsic sized functions to native code, and also expand the size of
Big Int to the next doubling.
This presupposes that the CPU size will need to keep up with the disk
addressing sizes.
|
|
| Back to top |
|
 |
Andrue Cope [TeamB] Guest
|
Posted: Mon Dec 12, 2005 5:28 pm Post subject: Re: Integral value > unsigned _int64? |
|
|
Bob Gonder wrote:
| Quote: | Well, yes, but to what purpose?
What are you going to do with that size?
I can only think of 3 things.
|
To copy it out. The code I'm writing is our runtime library and it's
providing low level I/O access exactly as the Win32 API does for
everyone else. If a file has that many bytes allocated to it I have to
address the issue somehow. Simply denying it or hiding it is not an
option any more than it would be for an operating system.
At present the guards are in place to catch this if/when it ever
happens but that still leaves a logical hole that I don't like. Past
experience has shown that to be a time bomb waiting to go off.
| Quote: | OTOH, if you are dead set on having really big numbers
|
At this moment in time it's not a pressing issue but I'll point out
that since this code is interpreting file systems created by operating
systems it's not us who are demanding anything. Quite a few modern file
systems have this potential dilemma.
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
Bob Gonder Guest
|
Posted: Tue Dec 13, 2005 7:07 am Post subject: Re: Integral value > unsigned _int64? |
|
|
Andrue Cope [TeamB] wrote:
| Quote: | To copy it out. The code I'm writing is our runtime library and it's
providing low level I/O access exactly as the Win32 API does for
|
So you're thinking seek() ?
I've seen Win handle it a few ways:
LowPart, HighPart
LowPart, *HighPart
These days you could probably get away with int64 for LowPart, and
stick with *HighPart. At some future time, *HighPart might point to 3
int64's to complete an int256. But that might have endian issues?
On a side note, just how big is 2^128, and how many atoms comprise the
Earth? IOW unless we manage to pack many megs into a single disk atom,
128 bit addressing should suffice.
|
|
| Back to top |
|
 |
Andrue Cope [TeamB] Guest
|
Posted: Tue Dec 13, 2005 9:14 am Post subject: Re: Integral value > unsigned _int64? |
|
|
Bob Gonder wrote:
| Quote: | On a side note, just how big is 2^128, and how many atoms comprise the
Earth? IOW unless we manage to pack many megs into a single disk atom,
128 bit addressing should suffice.
|
I would hope so but I like to have these things covered. It's amazing
some of the things we encounter especially if the file system has got
corrupted.
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|