Aug 13, 2022Kuina-chan

This is the reverse lookup dictionary 1 for exe execution environment of Kuin Programming Language, and is about how to handle numbers. ## 1Handling Integers And Decimals

### 1.1Handling Integers And Decimals

In Kuin, you use the int type for integers and the float type for decimals. They can perform basic arithmetic operations such as the four arithmetic operations (Figure 1-1).
Use the symbols "+" for addition, "-" for subtraction, "*" for multiplication, "/" for division, "%" for remainder of division, and "^" for power. You can write Kuin expressions in the same way as mathematical expressions, with multiplication being done before addition and parentheses changing the order of calculations.
The "/" operation on the int type will be truncated to the decimal point after the calculation.
When you write a number directly on the source code, if you write something like "5" or "-3", the number will be of type int, and if you write something with "." like "5.0" or "-3.0", the number will be of type float.

### 1.2Comparing Values

To compare the size of a value to a number of type int or float, use the comparison operators (Figure 1-2).
Each comparison operator is roughly equivalent to a mathematical symbol. The "<=" corresponds to " ", ">=" corresponds to " ", and "<>" corresponds to " ".
However, the float type is subject to calculation errors, so even if the comparison matches mathematically, comparing with "=" may return false. Therefore, the lib@same function can be used to make comparisons with some allowance for calculation errors (Figure 1-3).

### 1.3Convert Type

To convert between int and float types, use the cast operator "\$" (Figure 1-4).

### 1.4Obtain Absolute Value And Sign

For numbers of type int or float, use the .abs method for absolute values to make a negative number positive, and use the .sign method to get 1 if the sign is positive, -1 if negative, or 0 if zero (Figure 1-5).

### 1.5Set Value To Within Upper And Lower Limit

For numbers of type int or float, use the lib@min, lib@max, and lib@clamp functions to make the value within the upper and lower limits.
lib@min is a function that sets a number greater than x to x, lib@max is a function that sets a number less than x to x, and lib@clamp is a function that does both (Figure 1-6).

### 1.6Use Elementary Functions Such As Trigonometric Functions

To use elementary functions such as trigonometric functions, use the functions in lib@ (Figure 1-7).

### 1.7Generate Random Number

To generate random numbers, use the lib@rnd and lib@rndFloat functions (Figure 1-8).
lib@rnd and lib@rndFloat will return a different random number each time the program is invoked. If you want to reproduce the same random number sequence, use the lib@Rnd class (Figure 1-9).

### 1.8Perform Mathematical Calculations Such As Factorial And Prime Factorization

To perform mathematical calculations such as factorial and prime factorization, use the functions in math@ (Figure 1-10).

## 2Performs Bitwise Operations

To perform operations in bit units, use the bit8, bit16, bit32, and bit64 types (Figure 2-1).
The bit8, bit16, bit32, and bit64 types can handle sizes of 8, 16, 32, and 64 bits, respectively, and cannot handle negative values.
When writing bit8, bit16, bit32, and bit64 numbers directly in the source code, they are represented by adding the suffixes "b8", "b16", "b32", and "b64" after the number notation in the int type, respectively.
These types can perform bitwise operations such as and, or, not, and xor (Figure 2-2).

## 3Handling Character

### 3.1Handling Character

To handle characters in Kuin, the char type is used. When writing characters directly in the source code, enclose them in "'" to represent them.(Figure 3-1)。
The char type is internally an integer between 0x0000 and 0xFFFF, and characters are stored in UTF-16 character code. By using the "\$" operator to convert to the int type, you can operate directly in character code.

### 3.2Writing Special Characters Such As Newline Characters

To represent special characters such as line feeds in the source code, use a combination of the "\" character and a single character. For example, a newline character is written as "'\n'" (Figure 3-2).

## 4Handling Logical Value

### 4.1Handling Logical Value

Use the bool type when you want to handle logical values, such as when expressing conditions such as "if ...". The bool type has only two values: "true" for true, and "false" for false (Figure 4-1).
In Kuin, the symbol "|" is used for logical disjunction, which corresponds to "... or ...", and the symbol "&" is used for logical conjunction, which corresponds to "... and ...". You can also write "conditional expression ?(value when true, value when false)", you can also get the value according to the logical value (Figure 4-2).
The results of the "|" and "&" operators are shown in Table 4-1.
1660380149enf