A 64bit Double can hold much larger values than a 64bit Integer - how???
Floating-point types can represent a much wider range of values than integer types, and can store numbers that are much larger or smaller than can be stored in an Int . Swift provides two signed floating-point number types:
A 64bit Double can hold much larger values than a 64bit Integer - how???
Doubles are less precise
A 64 bit integer is 100% accurate through ALL values in the range it can hold
Not so for a Double - there are wide gaps in accuracy
Same is true for Xojo - but why?
Why ? why 2 types ? or something else ?
2 types is/was legacy in some cases - old FPU’s used to directly support one in hardware and the other in software. Thats no longer the case on most modern CPU’s
But they also can represent different ranges with different degrees of accuracy
See IEEE 754 - Wikipedia
Exactly
In an int ALL the bits represent the value
In a double or single some are the value and some are the exponent
And so they have fewer bits to represent the value - therefor less precision
But since they use a biased exponent they can represent a much wider range
The wikipedia article does explain this pretty reasonably
Its not intuitive for sure since in memory they both occupy 8 bytes
But, like so many things in computing, its not that they use X many bytes its how those bytes are interpreted as a specific kind of data that matters
I mean is &hf0 signed or unsigned ?
You cant tell just from the contents of a byte
It could be a 1 byte character, a Uint8, a signed Int8 or any one of several other kinds of things
And this is where the TYPE in a language like Xojo comes into play. Thats the hint to the compiler that you want this byte treated as whatever TYPE you said on the DIM line