Home Common Problem What does mod function mean?

What does mod function mean?

Aug 03, 2019 pm 02:37 PM
mod function

What does mod function mean?

The mod function is a remainder function, its format is: mod(nExp1,nExp2), which is the remainder after dividing two numerical expressions. Special note: In EXCEL, the MOD function is used to return the remainder of the division of two numbers. The sign of the returned result is the same as the sign of the divisor.

If you want to know more related knowledge, you can click: https://www.php.cn/faq/

Syntax: MOD(number,divisor)

Parameters:

Number is the dividend.

 Divisor is the divisor. [2]

 In Oracle, if divisor is 0, the function returns number directly.

Explanation:

The function MOD can be represented by the function INT: MOD(n, d) = n - d*INT(n/d)

Example:

MOD(3, 2) is equal to 1

MOD(-3, 2) is equal to 1

MOD(3, - 2) Equal to -1

 MOD(-3, -2) Equal to -1

 MOD(-3, 0) Equal to -3

 MOD(3, 0) Equal to 3

 MOD(2, 0) Equal to 2

 MOD(4, 3) Equal to 1

##Algorithm

1. Find the remainder of two integers with different signs

 1. Function value sign rules (sign of remainder)

mod (negative, positive)=positive, mod(-x, y): the obtained value is positive;

  mod(positive, negative)=negative, mod(x, -y): the obtained value is negative;

Conclusion: When finding the remainder of two integers, the sign of the value is the sign of the divisor.

 2. Value rules: First treat the two integers as positive numbers, and then perform the division operation

  ①When it can be divided evenly, the value is 0 (or not displayed )

  ②When it cannot be divided by integers, its value = divisor × (whole quotient 1)-divisor

Example: mod(36,-10)=-4 That is: the integer of 36 divided by 10 The quotient is 3, and after adding 1, it is 4; its product with the divisor is 40; and the difference with the dividend is (40-36=4); take the sign of the divisor. So the value is -4.

2. The rules for finding the remainder of two decimals:

After the dividend - (whole quotient × divisor), round off to the first decimal place.

Example: mod(9,1.2)=0.6, that is: the integral quotient of 9 divided by 1.2 is 7; the product of 7 and the divisor 1.2 is 8.4; the difference between the dividend 9 and 8.4 is 0.6. So the result is 0.6.

Example: mod(9,2.2)=0.2 That is: the integral quotient of 9 divided by 2.2 is 4; the product of 4 and the divisor 2.2 is 8.8; the difference between the dividend 9 and 8.8 is 0.2, so the result is 0.2 .

3. In VB, it is defined as the dividend and divisor are rounded first, and then divided to find the remainder

4. In Excel, the dividend is less than or equal to the divisor The integer value rule:

Example: mod(1,3)=1, mod(2,3)=2

The above is the detailed content of What does mod function mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Cyberpunk 2077 sees up to a 40% performance boost with new optimized path tracing mod Cyberpunk 2077 sees up to a 40% performance boost with new optimized path tracing mod Aug 10, 2024 pm 09:45 PM

One of the standout features ofCyberpunk 2077is path tracing, but it can put a heavy toll on performance. Even systems with reasonably capable graphics cards, such as the RTX 4080 (Gigabyte AERO OC curr. $949.99 on Amazon), struggle to offer a stable

Rabbit R1 gets modded to run games, performs better than expected Rabbit R1 gets modded to run games, performs better than expected Jun 29, 2024 am 07:50 AM

Earlier this month, a YouTuber named HowToMen showcased the Rabbit R1 running Android. With this mod, the device that was originally meant to be less distracting than a phone got to function like one. That isn't a bad thing, though, as Rabbit didn't

Tips for dynamically creating new functions in golang functions Tips for dynamically creating new functions in golang functions Apr 25, 2024 pm 02:39 PM

Go language provides two dynamic function creation technologies: closure and reflection. closures allow access to variables within the closure scope, and reflection can create new functions using the FuncOf function. These technologies are useful in customizing HTTP routers, implementing highly customizable systems, and building pluggable components.

Considerations for parameter order in C++ function naming Considerations for parameter order in C++ function naming Apr 24, 2024 pm 04:21 PM

In C++ function naming, it is crucial to consider parameter order to improve readability, reduce errors, and facilitate refactoring. Common parameter order conventions include: action-object, object-action, semantic meaning, and standard library compliance. The optimal order depends on the purpose of the function, parameter types, potential confusion, and language conventions.

How to write efficient and maintainable functions in Java? How to write efficient and maintainable functions in Java? Apr 24, 2024 am 11:33 AM

The key to writing efficient and maintainable Java functions is: keep it simple. Use meaningful naming. Handle special situations. Use appropriate visibility.

Complete collection of excel function formulas Complete collection of excel function formulas May 07, 2024 pm 12:04 PM

1. The SUM function is used to sum the numbers in a column or a group of cells, for example: =SUM(A1:J10). 2. The AVERAGE function is used to calculate the average of the numbers in a column or a group of cells, for example: =AVERAGE(A1:A10). 3. COUNT function, used to count the number of numbers or text in a column or a group of cells, for example: =COUNT(A1:A10) 4. IF function, used to make logical judgments based on specified conditions and return the corresponding result.

Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters Apr 21, 2024 am 10:21 AM

The advantages of default parameters in C++ functions include simplifying calls, enhancing readability, and avoiding errors. The disadvantages are limited flexibility and naming restrictions. Advantages of variadic parameters include unlimited flexibility and dynamic binding. Disadvantages include greater complexity, implicit type conversions, and difficulty in debugging.

What are the benefits of C++ functions returning reference types? What are the benefits of C++ functions returning reference types? Apr 20, 2024 pm 09:12 PM

The benefits of functions returning reference types in C++ include: Performance improvements: Passing by reference avoids object copying, thus saving memory and time. Direct modification: The caller can directly modify the returned reference object without reassigning it. Code simplicity: Passing by reference simplifies the code and requires no additional assignment operations.