စံကား

03Values and kinds

Writing integers

Burmese and Western digits, number bases, and kind prefixes.

A number written straight into a program, like ၄၂, is called a literal. Zaka accepts several forms of integer literal.

စံကား

Expected output

၁၂၃
၁၂၃
၁၀
၆၃
၂၅၅
၂၅၅

Digits

Use Burmese digits ၀ ၁ ၂ ၃ ၄ ၅ ၆ ၇ ၈ ၉ or Western digits 0 1 2 3 4 5 6 7 8 9, but not both in one number:

စံကားZK0103

Expected error

error[ZK0103]: Burmese and Western digits cannot be mixed in one number

Bases

အခြေ ... ဖြင့် reads "with base ...". It writes a number in a base from 2 to 36. Digits above 9 are the letters A to Z (upper or lower case): in base 16, A is ten and F is fifteen. The base itself is written in plain base 10.

ZakaReads as
အခြေ"base"
ဖြင့်"with"

The order of the parts

A full integer literal has up to three parts, in this fixed order:

  1. the base, အခြေ <n> ဖြင့် (optional),
  2. the kind, such as လက္ခဏာမဲ့ ၈ ဘစ် ကိန်းပြည့် (optional),
  3. the digits.

Negative numbers

There is no negative literal. -၅ is the minus operator applied to ၅. The word အနုတ် ("minus") does the same job. The compiler works out the result before the program runs, so the difference never shows.

စံကား

Expected output

-၅
-၅

Hands on

  • Print အခြေ ၂ ဖြင့် ၁၁၁၁၁၁၁၁. Which number in base 10 is it?
  • What does အခြေ ၂ ဖြင့် ၁၂ do? Read the message.

Next: Decimal numbers.