Questions tagged [modulus]

The remainder of the quotient of two numbers (usually integers).

847 questions
2
votes
1 answer

Angular2 modulus functionality to create rows of elements

I am having trouble recreating and imagining how to recreate the following piece of vanilla Javascript code in Angular2 (I just typed it out on the spot so don't worry about syntax or logic errors). As you can see, I am looping through an array of…
James
  • 2,800
  • 7
  • 45
  • 81
2
votes
0 answers

Javascript's Modulus broken?

I just found out that when you type Math.pow(5,25) % 5 in the console, it returns 2. This also happens when you first solve Math.pow(5,25) (298023223876953150 % 5 = 2). But that number is clearly divisible by 5, because it is a power of 5... Has…
user3722860
  • 189
  • 1
  • 3
  • 11
2
votes
4 answers

Big Integer Modular Exponentiation

How to calculate (xy) mod z with 1 <= x, y <= 101000 and z any positive integer 1 <= z < 231 ? What I have done so far is: scan x and y as a string, get the modulo, then calculate (xy) mod z. I know this is wrong because (xy) mod z is not equal to…
Ronald Sumbayak
  • 135
  • 2
  • 11
2
votes
3 answers

Modulus formula

I'm reading a C++ Primer 5th ed and i don't understand why is this true : The modulus operator is defined so that if m and n are integers and n is nonzero, then (m/n)*n + m%n is equal to m. I decided to check this and the result was indeed…
vdublevsky
  • 13
  • 5
2
votes
1 answer

Package.json when deploying Meteor on Modulus

I'm trying to push an updated version of my Meteor app to Modulus after switching dev environment but I now get the following: Client: Unable to connect to any application instances. Server: Now using node v6.2.0 Found package.json:…
oskare
  • 1,061
  • 13
  • 24
2
votes
1 answer

Is there a way to optimize reducing many numbers to the same modulus

I am writing a program to do integer factorization and have to reduce a series of numbers to a given modulus. Both the number and the modulus are bigints, say 50 to 100 digits. The number changes but the modulus is always the same. Is there some…
user448810
  • 17,381
  • 4
  • 34
  • 59
2
votes
1 answer

Rabin Karp algorithm for big strings

I wrote a simple step-by-step implementation of Rabin-Karp algorithm for substring search, and it seems to work fine until the hash becomes greater than the modulus, and then it goes wrong... Here is the code, it's quite simple: typedef long long…
Daniel
  • 7,357
  • 7
  • 32
  • 84
2
votes
1 answer

string formatting with modulus/percent sign

Is there something happening when string formatting that uses the modulus function while calling either StringOperand % TupleOperand or StringOperand % DictionaryOperand Or is it just an arbitrary use of % for the string formatting function? I'm…
MmmHmm
  • 3,435
  • 2
  • 27
  • 49
2
votes
1 answer

Add php code each 12 items starting from 2nd item

I have some loop. How can i optimize this code that it would be executed each 12 items starting from 2nd item. I'm using hardcoded code for each of +12 item, but of course this is not a good solution :) I know it's easy to do and i was trying to do…
MIC
  • 135
  • 2
  • 13
2
votes
1 answer

what does num%2 mean in java?

this is the code fragment. I'm not too sure what num%2 is though. % would give the remainder, so does that mean that the remainder of num must be 2? int num = 1, max = 20; while (num < max) { if (num%2 == 0) System.out.println(num); …
studentS
  • 41
  • 1
  • 1
  • 5
2
votes
2 answers

Text after % is not printing

I was just completing my assignment when I noticed that the text after the % symbol in double quotes is not printing. Here is a very easy example to show this: //program #include int main() { printf("remainder of 5%2 is :…
user5012346
2
votes
1 answer

Recursive Division Assembly program

I am working on an assembly, techincally HLA (High Level Assembly), program. I need to convert this C code to assemvbly. Here is the assignment. Write an HLA Assembly language program that implements the following function: procedure…
ecain
  • 1,282
  • 5
  • 23
  • 54
2
votes
2 answers

Efficient way to skip code every X iterations?

I'm using GameMaker Studio and you can think of it as a giant loop. I use a counter variable step to keep track of what frame it is. I'd like to run some code only every Xth step for efficiency. if step mod 60 { } Would run that block every 60…
veta
  • 716
  • 9
  • 22
2
votes
0 answers

Will mobile apps running meteor 1.1 still work if the server is updated to 1.2?

I've updated locally to 1.2 and the app runs well; if I deploy this local build to modulus and I still have lots of mobile cordova clients out there running older code, will they all still work together? I'm guessing a big update like this won't…
BellamyStudio
  • 771
  • 2
  • 9
  • 22
2
votes
2 answers

Java integer max test with clockwork modulus statement returning incorrect value

In class we're currently working with a "clockwise" modulus function - that is to say, a function which essentially works the same as Math.floorMod(int a, int b). For class, I cannot use Math.floorMod(), and I have written this after researching…
Jon Reed
  • 644
  • 1
  • 6
  • 12