Forum > General
Sizes and SizeInt
LemonParty:
I have notice that SetLength's Len parameter is declared as SizeInt. Also properties Size and Position of TStream are declared as Int64. Why this things are signed? Isn't a negative length is an absurd?
LeP:
I think, but I'm certainly wrong, that it's simply for general compatibility.
The vast majority of function arguments have historically been integers, although in many a negative value makes no sense.
However, this avoids the compiler having to perform uint/int conversions.
P.S.: I asked myself the same question, and I continue to ask it, when I have to remove all the warnings and hints from the code; here you can see how much this problem actually exists (I'm talking about Delphi, where the hints and warnings are always more or less zero).
marcov:
--- Quote from: LemonParty on June 09, 2026, 09:21:16 am ---I have notice that SetLength's Len parameter is declared as SizeInt. Also properties Size and Position of TStream are declared as Int64. Why this things are signed? Isn't a negative length is an absurd?
--- End quote ---
Pascal has a signed type as the base type. The highest unsigned number has some caveats in its use.
ALLIGATOR:
--- Quote from: marcov on June 09, 2026, 11:12:15 am ---The highest unsigned number has some caveats in its use.
--- End quote ---
https://graphitemaster.github.io/aau/
:)
Thaddy:
Memory allocations over UINT64 range are unlikely possible for many IONS, not centuries.
Then again, that might be a Bill Gates' 640k is enough trap.
A signed type makes the calculations safe.
It is still possible to allocate ridiculous amounts of memory, though, even High(Uint64), Just not for the classes and the standard compiler uses. Do you know how much high(Uint64) is? Not feasable, even on super computers. Missing hardware support....?
Answer: 1.8×10¹⁹ bytes, i.e. 16 exabytes. Not possible on any known hardware. 0.0092%, which is actually closer than I thought.... Then again: high (UINT64) is actually 1/12000 of all memory available worldwide.
If you compare High(UInt64) bytes (~16 EB) to the estimated total digital data on Earth (~200 ZB), that’s on the order of 0.01%. So it’s huge for a single process, but still tiny compared to what’s stored globally.
I copiloted the latter to be sure.
So IONS might be wrong, just wait a few years. Then we need a change to OctInt which will keep us happy for many moons...while maintaining integer calculations. :o :D ;D
Navigation
[0] Message Index
[#] Next page