Arduino Reference - Remainder
Maybe your like
- TUTORIALS
- HARDWARE & TOOLS
- REFERENCES
- FAQs
- ABOUT US
- English |
- Deutsch |
- Português |
- 한국어 |
- Français |
- Español
Sketch
- Function
- loop()
- setup()
Control Structure
- break
- continue
- do while
- if else
- for
- goto
- if
- return
- switch...case
- while
Further Syntax
- /* */ (block comment)
- {} (curly braces)
- #define (define)
- #include (include)
- ; (semicolon)
- // (single line comment)
Data Types
- array
- bool
- boolean
- byte
- char
- double
- float
- int
- long
- short
- size_t
- string
- String()
- unsigned char
- unsigned int
- unsigned long
- Variable
- void
- word
Constants
- constants
- Floating Point Constants
- Integer Constants
Variable Scope & Qualifiers
- const
- scope
- static
- volatile
Digital IO
- digitalRead()
- digitalWrite()
- pinMode()
Analog IO
- analogRead()
- analogReference()
- analogWrite()
Advanced IO
- noTone()
- pulseIn()
- pulseInLong()
- shiftIn()
- shiftOut()
- tone()
Serial
- Serial
- Serial.available()
- Serial.availableForWrite()
- Serial.begin()
- Serial.end()
- Serial.find()
- Serial.findUntil()
- Serial.flush()
- Serial.getTimeout()
- if(Serial)
- Serial.parseFloat()
- Serial.parseInt()
- Serial.peek()
- Serial.print()
- Serial.println()
- Serial.read()
- Serial.readBytes()
- Serial.readBytesUntil()
- Serial.readString()
- Serial.readStringUntil()
- serialEvent()
- Serial.setTimeout()
- Serial.write()
Stream
- Stream
- Stream.available()
- Stream.find()
- Stream.findUntil()
- Stream.flush()
- Stream.getTimeout()
- Stream.parseFloat()
- Stream.parseInt()
- Stream.peek()
- Stream.read()
- Stream.readBytes()
- Stream.readBytesUntil()
- Stream.readString()
- Stream.readStringUntil()
- Stream.setTimeout()
String Functions
- String.c_str()
- String.charAt()
- String.compareTo()
- String.concat()
- String.endsWith()
- String.equals()
- String.equalsIgnoreCase()
- String.getBytes()
- String.indexOf()
- String.lastIndexOf()
- String.length()
- String.remove()
- String.replace()
- String.reserve()
- String.setCharAt()
- String.startsWith()
- String.substring()
- String.toCharArray()
- String.toDouble()
- String.toFloat()
- String.toInt()
- String.toLowerCase()
- String.toUpperCase()
- String.trim()
String Operators
- String += (append)
- String == (comparison)
- String + (concatenation)
- String != (different from)
- String [] (element access)
- String > (greater than)
- String >= (greater than or equal to)
- String < (less than)
- String <= (less than or equal to)
Keyboard
- Keyboard
- Keyboard.begin()
- Keyboard.end()
- Keyboard Modifiers
- Keyboard.press()
- Keyboard.print()
- Keyboard.println()
- Keyboard.release()
- Keyboard.releaseAll()
- Keyboard.write()
Mouse
- Mouse
- Mouse.begin()
- Mouse.click()
- Mouse.end()
- Mouse.isPressed()
- Mouse.move()
- Mouse.press()
- Mouse.release()
Time
- delay()
- delayMicroseconds()
- micros()
- millis()
Math
- abs()
- constrain()
- map()
- max()
- min()
- pow()
- sq()
- sqrt()
Characters
- isAlpha()
- isAlphaNumeric()
- isAscii()
- isControl()
- isDigit()
- isGraph()
- isHexadecimalDigit()
- isLowerCase()
- isPrintable()
- isPunct()
- isSpace()
- isUpperCase()
- isWhitespace()
Bits and Bytes
- bit()
- bitClear()
- bitRead()
- bitSet()
- bitWrite()
- highByte()
- lowByte()
Arithmetic Operators
- + (addition)
- = (assignment operator)
- / (division)
- * (multiplication)
- % (remainder)
- - (subtraction)
Bitwise Operators
- << (bitshift left)
- >> (bitshift right)
- & (bitwise and)
- ~ (bitwise not)
- | (bitwise or)
- ^ (bitwise xor)
Boolean Operators
- && (logical and)
- ! (logical not)
- || (logical or)
Comparison Operators
- == (equal to)
- > (greater than)
- >= (greater than or equal to)
- < (less than)
- <= (less than or equal to)
- != (not equal to)
Compound Operators
- += (compound addition)
- &= (compound bitwise and)
- |= (compound bitwise or)
- ^= (compound bitwise xor)
- /= (compound division)
- *= (compound multiplication)
- %= (compound remainder)
- -= (compound subtraction)
- -- (decrement)
- ++ (increment)
Conversion
- byte()
- char()
- float()
- int()
- long()
- (unsigned int)
- (unsigned long)
- word()
Random Numbers
- random()
- randomSeed()
Trigonometry
- cos()
- sin()
- tan()
External Interrupts
- attachInterrupt()
- detachInterrupt()
Interrupts
- interrupts()
- noInterrupts()
Utilities
- PROGMEM
- sizeof()
Pointer Access Operators
- * (dereference operator)
- & (reference operator)
Zero, Due, MKR Family
- analogReadResolution()
- analogWriteResolution()
Description
Remainder operation calculates the remainder when one integer is divided by another. It is useful for keeping a variable within a particular range (e.g. the size of an array). The % (percent) symbol is used to carry out remainder operation.
Syntax
remainder = dividend % divisor;
Parameter Values
- remainder: variable. Allowed data types: int, float, double.
- dividend: variable or constant. Allowed data types: int.
- divisor: non zero variable or constant. Allowed data types: int.
Example Code
int x = 0; x = 7 % 5; // x now contains 2 x = 9 % 5; // x now contains 4 x = 5 % 5; // x now contains 0 x = 4 % 5; // x now contains 4 x = -4 % 5; // x now contains -4 x = 4 % -5; // x now contains 4 /* update one value in an array each time through a loop */ int values[10]; int i = 0; void setup() {} void loop() { values[i] = analogRead(0); i = (i + 1) % 10; // remainder operator rolls over variable }※ NOTES AND WARNINGS:
- The remainder operator does not work on floats.
- If the first operand is negative, the result is negative (or zero).
Therefore, the result of x % 10 will not always be between 0 and 9 if x can be negative.
See Also
- Language : + (addition)
- Language : = (assignment operator)
- Language : / (division)
- Language : * (multiplication)
- Language : - (subtraction)
※ ARDUINO BUY RECOMMENDATION
| Arduino UNO R3 |
| Arduino Starter Kit |
※ OUR MESSAGES
- We are AVAILABLE for HIRE. See how to hire us to build your project
Tag » Arduino Quotient And Remainder
-
% - Arduino Reference
-
Division - / - Arduino Reference
-
%= - Arduino Reference
-
Determining And Printing A Remainder In Ardunio IDE - Arduino Forum
-
Modulo / Remainder In Arduino - Tutorialspoint
-
Arduino Arithmetic Operators | Addition | Subtraction | Multiplication
-
Remainder Using Bitwise Operation In Arduino Sketch - Stack Overflow
-
Operators In Arduino Programming What Are They, What Are They ...
-
Fmod - C++ Reference
-
Div, Ldiv, Lldiv - Microsoft Docs
-
[PDF] Arduino-Reference.pdf
-
Wio Terminal: Arduino Customisable Timer