Remainder after division (modulo operation) (2024)

The concept of remainder after division isnot uniquely defined, and the two functions mod and rem eachcompute a different variation. The mod functionproduces a result that is either zero or has the same sign as thedivisor. The rem function produces a result thatis either zero or has the same sign as the dividend.

Another difference is the convention when the divisor is zero.The mod function follows the convention that mod(a,0) returns a,whereas the rem function follows the conventionthat rem(a,0) returns NaN.

Both variants have their uses. For example, in signal processing,the mod function is useful in the context ofperiodic signals because its output is periodic (with period equalto the divisor).

Remainder after division (modulo operation) (2024)
Top Articles
Latest Posts
Article information

Author: Sen. Emmett Berge

Last Updated:

Views: 6323

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Sen. Emmett Berge

Birthday: 1993-06-17

Address: 787 Elvis Divide, Port Brice, OH 24507-6802

Phone: +9779049645255

Job: Senior Healthcare Specialist

Hobby: Cycling, Model building, Kitesurfing, Origami, Lapidary, Dance, Basketball

Introduction: My name is Sen. Emmett Berge, I am a funny, vast, charming, courageous, enthusiastic, jolly, famous person who loves writing and wants to share my knowledge and understanding with you.