On 2020-01-12 20:03, Darren Duncan wrote:
On 2020-01-09 10:10 a.m., ToddAndMargo via perl6-users wrote:
A bug to report:
$ p6 'my uint32 $c; $c = "ABC";'
This type cannot unbox to a native integer: P6opaque, Str
in block <unit> at -e line 1
"uint32" is not an "integer". It is a cardinal. If
they really want to use the word "integer" for cardinal,
they should change the wording to "unsigned integer".
Picky, picky, picky
ToddAndMargo, you are wrong on this.
A uint32 is NOT specifically a cardinal.
Hi Darren,
Since a uint32 ca not be negative or a fraction,
it is a cardinal. Other operating system do call
them cardinals, such as Modula2. Pascal, C++ (I
think C too), Java, and so on and so forth.
At best you can say it can be characterized by a cardinal or be
isomorphic to one.
https://www.dictionary.com/browse/isomorphism
isomorphism
noun
Mathematics. a one-to-one relation onto the map
between two sets, which preserves the relations
existing between elements in its domain.
I am not following what you are getting at.
A uint32 is just as much an ordinal as a cardinal, so insisting on
calling it a cardinal means the type can't be used as an ordinal, or a
variety of other things.
https://www.dictionary.com/browse/ordinal-number
ordinal number
noun
Also called ordinal numeral. any of the numbers that
express degree, quality, or position in a series, as
first, second, and third *(distinguished from cardinal
number)*.
Mathematics. a symbol denoting both the cardinal number
and the ordering of a given set, being identical for
two ordered sets having elements that can be placed
into one-to-one correspondence, the correspondence
preserving the order of the elements.
https://www.dictionary.com/browse/cardinal-number
cardinal number
noun
Also called cardinal numeral. any of the numbers
that express amount, as one, two, three, etc.
*(distinguished from ordinal number)*.
No idea how you are mixing these two. I can see
how yo would use a cardinal in programming to
denote an ordinal, if that is what you are getting at.
Calling this an unsigned integer (u int) is much more accurate as it
doesn't presume a particular semantics such as that we are storing a
count rather than a position for example, it says what we actually know,
and no more.
I am sorry, I have no idea what you are trying to say. I do not care if
you call a cardinal an unsigned integer. Just
don't call it an integer. The high bit in a cardinal is
part of the number and denotes a negative number in an integer.
You are also wrong on saying that the values one can store in a uint32
are not integers; they definitely ARE integers. Every cardinal is an
integer.
Where do you get that. A cardinal can not be negative. An
Integer can. And the structure is even different: the high
bit in an integer denote the sign of the integer; the high bit
in a cardinal is just a higher positive number. So they
are not the same by any shake.
If you want to be precise, calling a uint32 an "unsigned integer" or
"cardinal" is inaccurate in the same way that calling it an "integer"
is.
Perfectly accurate. Unsigned integer and a cardinal are
exactly the same thing. The only difference is the
amount of letter you need to use to describe them.
Sort of like "associative array" and "hash"
In either case, the variable can only hold a proper subset of
either type, not all of them. If you're calling integer wrong then one
will have to call the type something like "integers in the range
0..^2**32".
-- Darren Duncan
The difference between a cardinal and an integer is
the high bit. Both are whole numbers. An integer
can be negative. A cardinal can not.
If you are going to error out something, say the proper
variable type you are error out on. Cardinal or unsigned
integer, I don't care which you call a cardinal. Whatever
floats your boat. Both descriptions are correct. Just
be correct.
-T
p.s. in assembly, they call a cardinal an unsigned integer.