The remainder of the quotient of two numbers (usually integers).
Questions tagged [modulus]
847 questions
-1
votes
2 answers
What could be a fix for a modulus error in C
I'd like to ask for help about this. I'm going to input two integers. All of the results are showing except for "modulus". Also the second and third "%d" is remaining as is. Here is the results when I run my program.
Enter First Number: 10
Enter…
-1
votes
1 answer
How to find a Modulus of a very large number (without a calculator)?
I was wandering if there was a trick here that I'm not aware.
For example (large number):
6612384^8
How can I apply mod 10?

Edward Chapman
- 509
- 6
- 8
-1
votes
2 answers
PHP % operator, what result should be returned?
$djs_all_num = mysql_num_rows($djs_all_db);
while($djs_all = mysql_fetch_array( $djs_all_db )) {
if ($djs_all_num % "2") {
With my if () statement, this should halve the amount of rows, and so in the else further on it should…

Sam
- 6,616
- 8
- 35
- 64
-1
votes
4 answers
Why cant I assign a remainder to a new variable??? JAVA
int d = year%100;
int c = year/100;
int valueA = (int)(((13*monthnumber)-1)/5);
int valueB = (int) d/4;
int valueC = (int) c/4;
int weekDay = (d + valueA + d + valueB + valueC - 2*c);
int remainder %= weekDay/7;
im…

user3185727
- 159
- 1
- 3
- 12
-1
votes
4 answers
Keep a double at a max of 1.0
Ok this should be a rather simple problem but I just can't get this right. I have a cumulative sum that's returning a double. These represent percents and it should never be 0.0.. so I figured use d % 1 to keep things under 1. Works fine for…

wizard_draziw
- 505
- 1
- 5
- 17
-1
votes
1 answer
How to count number of divisible terms without using modulus operator?
Given three numbers N, A and B. Find how integers in range from 1 to N are divisible by A or B. I can't use modulus operator from range 1 to N because N can be as large as 10^12 and then I would run out of allocated time for the program to produce…
-1
votes
3 answers
Java Modulus with Double
So I was working with some modulus and I was confused as to why when I do
.3%.1
I get
0.09999999999999998
instead of 0... How do I fix this?

TMKang
- 11
- 1
-1
votes
2 answers
Java modulus left hand operand smaller than right hand operand
How java calculate remainder if left operand is smaller than left operand?
public class ModulusTest {
public static void main(String[] args) {
int a = 3 , b = 10;
int modul1 = b%a;
System.out.println("b modulus a = " +…

Gerardas
- 338
- 5
- 9
-1
votes
1 answer
ANSI C / rand() % 7 first value is always 3
So trying to figure out what is special about rand() mod k7 in C. In another post someone said that C rand() uses http://en.wikipedia.org/wiki/Linear_congruential_generator but I don't see what makes (mod k7) k-> scalar special for the algorithm…

Thomas
- 201
- 1
- 3
- 12
-1
votes
2 answers
modulus and int for note calculations
Java input;
import java.util.*;
public class NetPay3
{
public static void main()
{
// Define Scanner object
Scanner inLine = new Scanner (System.in);
// Define other variables
float pay;
int…

user3362899
- 23
- 5
-1
votes
3 answers
Modulus Visual Studio 2013
I was just wondering how I could state if x + y + z % 2 == 0 BUT only do this statement IF the three values aren't set to 0. I require the values to be 0.
Example of my code & posStatus may hold variables of the value 0. The problem is when all…

Zain
- 1,246
- 4
- 15
- 26
-1
votes
1 answer
python big number mod
I'm doing mod for big number in python 2.7.3 and python is giving me wrong answer as shown below. If number is small, then it gives correct answer.
Can anybody explain why this happens and how I can fix in python??
below simple script showing small…

user3022431
- 63
- 1
- 1
- 5
-1
votes
1 answer
(a mod 2*x)-(a mod x)
I am trying to find the possible values of this expression.
(a mod 2*x)-(a mod x)
I suspect they might be 0 or x, but I'm really not sure. I can't seem to be able to write down a proper argument.

user1377000
- 1,433
- 3
- 17
- 29
-1
votes
4 answers
Need assistance with output of minutes using mod in C?
Possible Duplicate:
Why can’t decimal numbers be represented exactly in binary?
#include
int main(void)
{
int temperature, time;
float minutes;
printf("What is the Fahrenheit temperature?\n");
…

anon_nerd
- 1,251
- 1
- 10
- 16
-1
votes
3 answers
Python code with %
Can anybody explain me the following code. I did not understand what % does. As I know it returns remainder, but I did not get the output i was expecting. What is remainder itself? can you please explain output step by step.
for num in range(20):
…

Jamol
- 3,768
- 8
- 45
- 68