App Inventor 2 | Math

Math Blocks

** Chú thích : Bất kỳ block nào trong Math đều có thể sử dụng với block số đơn giản "Block số 0 trong math".

Bạn không tìm thấy 1 khối phép tính nào đó?

Một số khối được ghép chung với nhau, điều đó có nghĩa nếu bạn cần dùng bạn sẽ nhấn vào block nào đó và nhấn vào mũi tên xổ xuống, nó sẽ nằm trong danh sách xổ xuống đó. Dưới đây là danh sách 1 số phép tính được giấu trong menu xổ xuống:
=, ≠, >, ≥, <, ≤
min, max
square root, absolute, neg, log, e^, round, ceiling, floor
modulo of, remainder of, quotient if
sin, cos, tan, asin, acos, atan
convert radians to degrees, convert degrees to radians

Basic Number Block

Can be used as any positive or negative number (decimals included). Double clicking on the "0" in the block will allow you to change the number.

=

Tests whether two numbers are equal and returns true or false.

#

Tests whether two numbers are not equal and returns true or false.

>

Tests whether the first number is greater than the second number and returns true or false.

Tests whether the first number is greater than or equal to the second number and returns true or false.

<

Tests whether the first number is less than the second number and returns true or false.

Tests whether the first number is less than or equal to the second number and returns true or false.

+

Returns the result of adding any amount of blocks that have a number value together. Blocks with a number value include the basic number block, length of list or text, variables with a number value, etc. This block is a mutator and can be expanded to allow more numbers in the sum.

-

Returns the result of subtracting the second number from the first.

*

Returns the result of multiplying any amount of blocks that have a number value together. It is a mutator block and can be expanded to allow more numbers in the product.

/

Returns the result of dividing the first number by the second.

^

Returns the result of the first number raised to the power of the second.

random integer

Returns a random integer value between the given values, inclusive. The order of the arguments doesn't matter.

random fraction

Trả về giá trị ngẫu nhiên trong khoảng từ 0 đến 1 (ví dụ: 0.042, 0.973, 0.635....)

random set seed to

Use this block to generate repeatable sequences of random numbers. You can generate the same sequence of random numbers by first calling random set seed with the same value. This is useful for testing programs that involve random values.

min

Returns the smallest value of a set of numbers. If there are unplugged sockets in the block, min will also consider 0 in its set of numbers. This block is amutator and a dropdown.

max

Returns the largest value of a set of numbers. If there are unplugged sockets in the block, max will also consider 0 in its set of numbers. This block is amutator and a dropdown.

square root



Phép tính lấy căn bậc 2 của 1 số.

absolute




Luôn trả về giá trị tuyệt đối cho 1 số. ( ví dụ : -2 = |2| ; -15 = |15| ; 23 = |23|....)

neg




Trả về giá trị âm của 1 số. ( ví dụ :  23 = -23; 12 = -12; 2 = -2; ....)

log

Returns the natural logarithm of a given number, that is, the logarithm to the base e (2.71828...).

e^

Returns e (2.71828...) raised to the power of the given number.

round

Trả về giá trị làm tròn của số thập phân.( ví dụ :  24.5  ~ 24 ; 25.3 ~ 25 ; 65.6 ~ 66 ; ....)

ceiling

Trả về kết quả là số nguyên cho số thập phân, khác với "round", ceiling sẽ trả về giá trị số nguyên luôn lớn hơn số ban đầu ( ví dụ : 23.3 ~ 24; 34.1 ~ 35; 54.8 ~ 55; .....)

floor

Floor cũng trả về kết quả là số nguyên cho số thập phân, nhưng khác với ceiling trả về giá trị cao hơn giá trị ban đầu thì floor lại trả về giá trị bằng giá trị ban đầu. ( ví dụ : 23.3 ~ 23; 34.1 ~ 34; 54.8 ~ 54; ....)

modulo

Modulo(a,b) is the same as remainder(a,b) when a and b are positive. More generally, modulo(a,b) is defined for any a and b so that (floor(a/b)× b) + modulo(a,b) = a. For example, modulo(11, 5) = 1, modulo(-11, 5) = 4, modulo(11, -5) = -4, modulo(-11, -5) = -1. Modulo(a,b) always has the same sign as b, while remainder(a,b) always has the same sign as a.

remainder

Phép chia lấy số dư của 2 số (a,b). (Ví dụ : remainder(25,10) = 5 bởi vì:
25/10 = 2 dư 5 )
Tương tự như vậy, 1 số ví dụ khác như: remainder(12, 10) = 2; remainder(-35, 10) = -5; remainder(35, -10) = 5 và cuối cùng là remainder|(-35, -10) = -5.

quotient

Phép chia lấy số nguyên của 2 số (a,b)
Ví dụ: quotient(25,10) = 2; quotient(53,10) = 5; quotient(66,10) = 6.....

sin

Trả về kết quả Sin của 1 số (degrees chứ không phải radian)

cos

Trả về kết quả Cos của 1 số (degrees chứ không phải radian)

tan

Trả về kết quả Tan của 1 số (degrees chứ không phải radian

asin

Trả về kết quả asin của 1 số (degrees chứ không phải radian)

acos

Trả về kết quả acos của 1 số (degrees chứ không phải radian)

atan

Trả về kết quả atan của 1 số (degrees chứ không phải radian)

atan2

Trả về kết quả Sin của y/x số (degrees chứ không phải radian)Returns the arctangent of y/x.

convert radians to degrees

Trả về kết quả sau khi chuyển đổi đơn vị từ radian sang degree. Kết quả sẽ trả về giá trị "độ" nằm trong khoảng từ 0 độ đến 360 độ.

convert degrees to radians

Ngược lại với "Convert rad to deg", block này sẽ chuyển đơn vị từ deg sang rad. Và kết quả sẽ là giá trị nằm trong khoảng [-π , +π)

format as decimal

Formats a number as a decimal with a given number of places after the decimal point. The number of places must be a non-negative integer. The result is produced by rounding the number (if there were too many places) or by adding zeros on the right (if there were too few).

is a number

Returns true if the given object is a number, and false otherwise.

convert number

Takes a text string that represents a positive integer in one base and returns a string that represents the same number is another base. For example, if the input string is 10, then converting from base 10 to binary will produce the string 1010; while if the input string is the same 10, then converting from binary to base 10 will produce the string 2. If the input string is the same 10, then converting from base 10 to hex will produce the string A.