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
0
votes
1 answer

How to perform a reverse mod?

If I have an equation like (x+c) mod y = z and I need to solve for y, how would I go about doing that? Apologies if this is more math than programming.
display name
  • 43
  • 1
  • 1
  • 4
0
votes
1 answer

mySql select unique number for every 3 records

I'm trying to get a unique number in 'row' column for every {variable} 3 records. (So I know we have these 3 skus on the first row etc.) Like this: line sku row 1 aaa 1 2 abb 1 3 abc 1 4 acc 2 5 acb 2 6…
joell
  • 71
  • 1
  • 4
  • 18
0
votes
1 answer

Rewrite Rule absolute path error

i have a problem with .htaaccess file. I'm trying to transform url like www.example.com/news/2 to www.example.com/index.php?news=$1. So far i've tried: RewriteRule ^news/([0-9]+)/?$ /index.php?news=$1 [NC,L] This leads me to an error because it…
U.Alex
  • 59
  • 1
  • 7
0
votes
2 answers

How can I do modular arithmetic with decimal values in Python?

Say I want to do something like 9.9 % 13 The normal python modulo will give me an output of 9.9. Are there any modules I can import that will instead give me an output of 6 (or more generally an integer value)?
UBears
  • 371
  • 1
  • 4
  • 18
0
votes
1 answer

Use mod_rewrite to insert string in URL for all files in a directory

I'm looking to use mod_rewrite to insert a string before the extension on all files in a specific url. Example: example.com/products/this-is-a-product.html add this (-cool): example.com/products/this-is-a-product-cool.html to every URL in the…
0
votes
1 answer

How to mod_rewrite "ONE file" from .php to .html in .htaccess?

What is the syntax to mod_rewrite "ONE file" from .php to .html in .htaccess? I have syntax for ALL files, but how do I do that for one file? Thanks
Doktorek
  • 1
  • 1
0
votes
0 answers

Modulo calculation with negative dividend

I did some research on GCC's % operator and it seems it doesn't calculate the correct value if it has a negative dividend. Well, I know all the relevant rules of GCC. Anyway, -3%5 is -3 by GCC and 2 by Math I'm using this macro now to correct…
Daniel
  • 2,318
  • 2
  • 22
  • 53
0
votes
2 answers

How can I use MOD function within WHILE LOOP with PLS_INTEGER data type?

I'm trying to print on screen odd values of an associative array using a simple "WHILE LOOP" with MOD condition. Is it possible? I know that PLS_INTEGER only accept not decimal values (like int datatype on Java). So... I tried with a NUMBER counter…
user6611026
0
votes
1 answer

Want to know how to find Modulo of a decimal number with 10^9 + 7?

I was going through a coding competition. it asked there is decimal number and we have to find its modulo by 10^9 + 7(1000000007). the simple test cases were 1.23 should give output 110000002 4.0 should give output 4. i was unable to understand…
ashit
  • 1
  • 3
0
votes
1 answer

Newbie: Using $mod method during insert in mongodb

I'm sure this is the easiest question for you, but forgive me for being naive. I have been trying to learn mongodb and wanted to experiment with some aggregation. For that, I wanted to insert data into a collection like this. for (i=1; i<=10; i++) {…
Radha
  • 15
  • 4
0
votes
0 answers

Getting inaccurate remainders with modulus operator (%)

I'm new to Java and learning about the % operator. However I have a problem: System.out.println(510%5); //this produces a correct output of 0 System.out.println((5.1*100)%(0.05*100)); //but this produces 4.9999 Technically they're the same numbers,…
0
votes
1 answer

function for calculate specific mod in python3

I have four big numbers (up to 100 digits) like m, y, n, r that m * y mod n = r. I know the value of m,n and r and I wanna find the value of y. Is there a function in python3 to do this? (like the powmod function in gmpy2)
Richard
  • 69
  • 2
  • 10
0
votes
1 answer

How can you legally perform the mod operator on a rounded double?

I am trying to implement the mod operator on a double that is temporarily converted to an integer (rounded), but the compiler (clang) doesn't seem to like that and returns the error: assignment to cast is illegal, lvalue casts are not supported.…
Josh Simani
  • 107
  • 10
0
votes
1 answer

htaccess rule for any keyword to a physical sub-folder

I am struggeling with something I am trying to do regarding folder. I have a sub-folder called "admin" so I can access the site as mydomain.com/admin. However I want that if I say mydomain.com/foobar or mydomain.com/28y282djdhjd, then it should…
Mihai Pop
  • 65
  • 6
0
votes
0 answers

How to calculate how many items will fit in a box using MOD?

so I am trying to finish my school project but I am stuck in the last process. I need to print the total price and the amount of boxes and the price of each. The user needs to input how many bags of coffee he wants, each bag costs 1000, and there…