How to calculate remainder in javascript

藏色散人
Release: 2023-01-07 11:43:13
Original
11946 people have browsed it

In JavaScript, you can use the remainder operator "%" to achieve numerical remainder. The syntax is such as "result = number1 % number2", and the return value is the remainder.

How to calculate remainder in javascript

The operating environment of this article: Windows 7 system, javascript1.8.5, Dell G3 computer.

How to calculate the remainder in javascript?

Remainder operator in javascript

Remainder operator (%)

An expression Divides the value of another expression by the value of another expression, returning the remainder.

result = number1 % number2
Copy after login

Parameters

result

Any variable.

number1

Any numerical expression.

number2

Any numerical expression.

Description

The remainder (or remainder) operator divides number1 by number2 (rounding the floating point number to an integer), and then returns only the remainder as the result. For example, in the following expression, A (result) is equal to 5.

A = 19 % 6.7
Copy after login

Recommended study: "javascript Advanced Tutorial"

The above is the detailed content of How to calculate remainder in javascript. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template