๐Ÿ“˜ The number ฯ€ in Perl 6

Print the value of ฯ€.

The value of  is accessible with no additional modules:

say ฯ€;

This instruction, not a surprise, prints the desired value:


As you may have noticed, a non-ASCII character was used in the code. Perl 6 assumes that the source code is encoded as UTF-8 by default. Instead, a non-Unicode version can be used, too:

say pi;

There are a couple more constants built-in in Perl 6:ย tau andย e; both of them have Unicode variants:ย ย andย ย (character codeย 0x1D452):

say ฯ„;
sayย e;

The value ofย tau is equal toย 2ฯ€, and the above program prints the following result:


It is also worth knowing that in Perl 6, thereโ€™s a special constant for presenting infinity:ย Inf orย โˆž. This number is bigger than any other (reasonably big) number; either an integer or a floating-point value.

say 1E120 <ย โˆž;ย # Prints True

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s