Re: Cardinals

2020-01-03 Thread ToddAndMargo via perl6-users

On 2020-01-03 01:07, Darren Duncan wrote:
Todd, nothing you said disagrees with what I said, and I referenced that 
same Wikipedia article.  (Though perhaps I could have been more accurate 
in saying a cardinal is characterized by an integer rather than saying 
it is an integer with a particular interpretation.)  In particular, the 
article is explicit that there is no limit to how many cardinal numbers 
there are.  So saying cardinal number is equivalent to a fixed size 
32-bit integer is wrong, which is my point. (Also, negative 
quantities/counts are a common concept, but I can accept that 
the formal definition of cardinal excludes them.) -- Darren Duncan


Hi Darren,

I was just trying to come up with a type that Raku
would not think was a negative number if the first
bit was set.  uint16 and uint32 are perfect for this.

No uint8 though, but BYTE and Buf work for that.

I personally had never heard the term Cardinal until
I used Modula2.  A cardinal was always called
"counting numbers" in publik skool, probably because
they wanted to avoid the jokes about red birds.

:-)

-T


Re: Cardinals

2020-01-03 Thread Darren Duncan
Todd, nothing you said disagrees with what I said, and I referenced that same 
Wikipedia article.  (Though perhaps I could have been more accurate in saying a 
cardinal is characterized by an integer rather than saying it is an integer with 
a particular interpretation.)  In particular, the article is explicit that there 
is no limit to how many cardinal numbers there are.  So saying cardinal number 
is equivalent to a fixed size 32-bit integer is wrong, which is my point. 
(Also, negative quantities/counts are a common concept, but I can accept that 
the formal definition of cardinal excludes them.) -- Darren Duncan


On 2020-01-03 12:03 a.m., Todd Chester via perl6-users wrote:



On 2020-01-02 22:19, Darren Duncan wrote:

On 2020-01-02 10:01 a.m., ToddAndMargo via perl6-users wrote:

How do I do a 32 bit unsigned integer (cardinal)?  I
have a situation where I need to be able to have the
first bit be a one and not have Raku think it is
a negative number.


Why do you use the term "cardinal" to refer to a 32 bit unsigned integer?

The term "cardinal" in practice is just an integer/number of any magnitude 
with the added semantics of representing a quantity/count of something in 
contrast to say an ordinal position or name of something.


Cardinals can't be negative.  Think of them as counting numbers



The term definitely does not represent a fixed-size number and it can also be 
negative.


You are confusing a cardinal with an integer.  An easy mistake
to make


-- Darren Duncan


Hi Darren,

Cardinal number
https://simple.wikipedia.org/wiki/Cardinal_number

  "Cardinal numbers (or cardinals) are numbers that say how
  many of something there are, for example: one, two,
  three, four, five, six. They are sometimes called
  counting numbers. "


Cardinal Numbers
https://www.mathsisfun.com/numbers/cardinal-ordinal-nominal.html

     "A Cardinal Number says how many of something there are,
     such as one, two, three, four, five.

     A Cardinal Number answers the question 'How Many?'"


Modula-2 Basic Data Types
https://www.modula2.org/sb/env/index75.htm

     CARDINAL   16-bit compiler:   2 bytes  0 to 65535
    32-bit compiler:   4 bytes  0 to 4,294,967,295

I was pretty good at Modula2 back in the day,

:-)

-T



Re: Cardinals

2020-01-03 Thread Todd Chester via perl6-users




On 2020-01-02 22:19, Darren Duncan wrote:

On 2020-01-02 10:01 a.m., ToddAndMargo via perl6-users wrote:

How do I do a 32 bit unsigned integer (cardinal)?  I
have a situation where I need to be able to have the
first bit be a one and not have Raku think it is
a negative number.


Why do you use the term "cardinal" to refer to a 32 bit unsigned integer?

The term "cardinal" in practice is just an integer/number of any 
magnitude with the added semantics of representing a quantity/count of 
something in contrast to say an ordinal position or name of something.


Cardinals can't be negative.  Think of them as counting numbers



The term definitely does not represent a fixed-size number and it can 
also be negative.


You are confusing a cardinal with an integer.  An easy mistake
to make


-- Darren Duncan


Hi Darren,

Cardinal number
https://simple.wikipedia.org/wiki/Cardinal_number

 "Cardinal numbers (or cardinals) are numbers that say how
 many of something there are, for example: one, two,
 three, four, five, six. They are sometimes called
 counting numbers. "


Cardinal Numbers
https://www.mathsisfun.com/numbers/cardinal-ordinal-nominal.html

"A Cardinal Number says how many of something there are,
such as one, two, three, four, five.

A Cardinal Number answers the question 'How Many?'"


Modula-2 Basic Data Types
https://www.modula2.org/sb/env/index75.htm

CARDINAL   16-bit compiler:   2 bytes  0 to 65535
   32-bit compiler:   4 bytes  0 to 4,294,967,295

I was pretty good at Modula2 back in the day,

:-)

-T


Re: Cardinals

2020-01-02 Thread Darren Duncan

On 2020-01-02 10:01 a.m., ToddAndMargo via perl6-users wrote:

How do I do a 32 bit unsigned integer (cardinal)?  I
have a situation where I need to be able to have the
first bit be a one and not have Raku think it is
a negative number.


Why do you use the term "cardinal" to refer to a 32 bit unsigned integer?

The term "cardinal" in practice is just an integer/number of any magnitude with 
the added semantics of representing a quantity/count of something in contrast to 
say an ordinal position or name of something.


The term definitely does not represent a fixed-size number and it can also be 
negative.


-- Darren Duncan


Re: Cardinals

2020-01-02 Thread Todd Chester via perl6-users




On 2020-01-02 10:14, Tobias Boege wrote:

On Thu, 02 Jan 2020, ToddAndMargo via perl6-users wrote:

Hi All,

  “He who asks is a fool for five minutes, but he who
  does not ask remains a fool forever.”
  ― Mark Twain

This would be my five minutes.  I will live.

How do I do a 32 bit unsigned integer (cardinal)?  I
have a situation where I need to be able to have the
first bit be a one and not have Raku think it is
a negative number.




It's called uint32: 
https://docs.perl6.org/language/nativetypes#index-entry-uint32



Hi Tobias,

Perfect!   Thank you!

-T


p6 'my uint16 $x = 0x8765;
my int16  $y = 0x8765;
say $x.base(0x10);
say $y.base(0x10);'

8765
-789B


p6 'my uint16 $x = 0x8765;
$x += 0xFF;
say $x.base(0x10);'

8864


p6 'my uint16 $x = 0x8765;
my int16 $y = $x +| 0x00;
say $x.base(0x10); say $y.base(0x10);'

8765
-789B


p6 'my uint16 $x = 0x4ABC;
$x = $x +< 1;
say $x.base(0x10);'
9578


p6 'my uint16 $x = 0x4ABC;
$x += $x;
say $x.base(0x10);'

9578


Re: Cardinals

2020-01-02 Thread Tobias Boege
On Thu, 02 Jan 2020, ToddAndMargo via perl6-users wrote:
> Hi All,
> 
>  “He who asks is a fool for five minutes, but he who
>  does not ask remains a fool forever.”
>  ― Mark Twain
> 
> This would be my five minutes.  I will live.
> 
> How do I do a 32 bit unsigned integer (cardinal)?  I
> have a situation where I need to be able to have the
> first bit be a one and not have Raku think it is
> a negative number.
> 

It's called uint32: 
https://docs.perl6.org/language/nativetypes#index-entry-uint32

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


Cardinals

2020-01-02 Thread ToddAndMargo via perl6-users

Hi All,

 “He who asks is a fool for five minutes, but he who
 does not ask remains a fool forever.”
 ― Mark Twain

This would be my five minutes.  I will live.

How do I do a 32 bit unsigned integer (cardinal)?  I
have a situation where I need to be able to have the
first bit be a one and not have Raku think it is
a negative number.

Many thanks,
-T