Questions tagged [mod]

For questions related with the *mod operation*, that can arise in Cryptography, Number Theory, Hashing, etc..

In computing, the modulo operation finds the remainder after division of one number by another (sometimes called modulus). Given two positive numbers, a (the dividend) and n (the divisor), a modulo n (abbreviated as a mod n) is the remainder of the Euclidean division of a by n.

437 questions
2
votes
2 answers

Faster mod operation for large numbers in Java

I need to check whether X is divisible by Y or Not. I don't need the actual remainder in other cases. I'm using the "mod" operator. if (X.mod(Y).equals(BigInteger.ZERO)) { do something } Now, I'm interested only when X is divisible by Y, I…
User_67128
  • 1,230
  • 8
  • 21
2
votes
1 answer

Image manipulation in Python using PIL and facing problem with fromarray()

I am writing a script to encrypt and decrypt an image in python3 using PIL. Here I am converting the image into a numpy array and then multiplying every element of the array with 10. Now I noticed that the default function in PIL fromarray() is…
Sandipan
  • 683
  • 8
  • 25
2
votes
2 answers

How to find A%B for A and B are very large numbers (stored in string)

If I have two numbers A and B and I want to compute A%B for A and B are very large (as large as 10^100), both are stored in strings, how can I achieve that?
2
votes
1 answer

How can I use a mod in an array using numpy

Let's say I have an array a = ([6,8,10,13,15,18,21]) I have another array b= ([2,5]) I want to return an array which gives me nonzero values of a%b. If any value in a mod any value in b equals zero, I don't want to return it. c = ([13,21]) Using…
2
votes
3 answers

Selecting every nth row with a condition in SQL

This seems a conceptually easy question, but with no straightforward answer. I have some time-serious data, with a whole bunch (millions) of unique events given by the event_ID variable, describing a set (of several) physical properties…
npross
  • 1,756
  • 6
  • 19
  • 38
2
votes
1 answer

Is there a function for integer fmod in C++?

http://en.cppreference.com/w/c/numeric/math/fmod Alright, cool. There's this function called fmod, but it appears to only work with float, double, and long double. Is there a version of this function that works with integers in C++?
Aaron Franke
  • 3,268
  • 4
  • 31
  • 51
2
votes
5 answers

Fast modulo 10 in c

I am looking for a fast modulo 10 algorithm because I need to speed up my program which does many modulo operations in cycles. I have checked out this page which compares some alternatives. As far as I understand it correctly, T3 was the fastest of…
mrRobot
  • 301
  • 3
  • 12
2
votes
0 answers

ARM Assembly divisibility testing without hardware UDIV instruction

I'm having trouble coding in ARM Assembly, I have to code something in order to say if r0 is divisible by r1, so I was going to code the modulo to say if r0 % r1 == 0 but maybe there's a better way (performing speaking) to what I want? I found this…
Axel Carré
  • 303
  • 1
  • 5
2
votes
1 answer

Big Integer Swift 4.0

I want to perform a big mod (%) operation like the example below: 083123456787654325500479087654 % 55 As you can see this number is bigger than Int64.max (9223372036854775807) I tried to parse this "083123456787654325500479087654" from string into a…
2
votes
1 answer

Couldn't match expected type ‘Integer -> t’ with actual type ‘Bool’

In Haskell, This works perfectly fine:(mod 9) 7. It gives the expected result: remainder when 9 is divided by 7 (2). Similarly, this works too:(mod 9) 9. It returns 0. This led me to think that (mod 9 == 0) 9 should return True. However, that hasn't…
spideyonthego
  • 123
  • 1
  • 10
2
votes
1 answer

How do you decrement using modulo in this specific example?

I have this bit of code: [deleted due to unwanted plagiarism] This is a simplified version of the Enigma machine used during World War II. The decrypting part of this code does not work well and returns HFFDGRHC instead of HELLOBOY. Would anyone…
ShadowWolf
  • 51
  • 8
2
votes
2 answers

How to compute a^b^c mod p?

I am trying to compute a^b^c mod p for some positive integers a,b,c,p. One possible (and obvious) way is to use fast modular exponentiation which will run in O(log(b^c))=clog(b). While I don't mind the efficiency here, the obvious downfall of this…
AspiringMat
  • 2,161
  • 2
  • 21
  • 33
2
votes
0 answers

Apache mod_substitute replace first occurence only

I am quite new to Apache HTTP Server. I am using the mod_substitute to transform urls like http://www.example.com/appName/... into http://www.example.com**/root**/appName/... My problem is handling urls like…
Rijndaal
  • 21
  • 4
2
votes
1 answer

how to find mod_wsgi.so file

I have successfully run the python setup.py install but finding it difficult to locate mod_wsgi.so file so that I can paste it in apache folder. Pls some one guide me in this regard Thanx in advance
2
votes
1 answer

Use mod to calculate which row was tapped in?

This is more of a math problem really. I have a 3 column grid and am trying to determine which row a tap was in. I just can't quite work out the math so that a tap of item 0,1,2 will output 0 and a tap of 3,4,6 will output a 1 etc. Any ideas for how…
Fuego DeBassi
  • 2,967
  • 6
  • 29
  • 37