Questions tagged [modulus]

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

847 questions
3
votes
1 answer

openssl: how can i get public key from modulus

I generate a pair of keys using openssl: shell> ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/Users/mike/.ssh/id_rsa): /path/to/test_rsa Enter passphrase (empty for no passphrase): Enter same…
Mike.G
  • 87
  • 3
  • 9
3
votes
2 answers

Why can't a variable be incremented in an assignment operator?

As a preface, I am using eclipse 3.7.2 on Mint 12x64 Suppose you have the given fields: tail = 10; capacity = 10; Now suppose you were to execute this statement: tail++ %= capacity; Why is the statement illegal? Is the statement ambiguous? To me…
ahodder
  • 11,353
  • 14
  • 71
  • 114
3
votes
1 answer

Generate RSA Public key from modulus and exponent in bytes in Objective-c

I'd searching many websites trying to understand how does RSA works. I have a modulus…
Carlos Mayoral
  • 313
  • 3
  • 12
3
votes
3 answers

Determining the next highest number that can be factored into prime numbers {2,3,5,7}

I would like to write a function that is given an unsigned integer as an input argument and returns the next highest number that can be factored into prime numbers {2, 3, 5, 7}. Here is a short code snippet showing what I want to do. unsigned int…
Nicholas Kinar
  • 1,440
  • 5
  • 24
  • 36
3
votes
2 answers

Shell Programming with Modulus Operation

I'm trying to write a shell program that, given an argument, prints the name of the program and every odd word in the argument (that is, not even words). However, I am not getting the expected result. Upon tracing my program, I notice that, despite…
user1696230
3
votes
5 answers

modulus of negative numbers in Python

23 % -5 = -2 23 % 5 = 3 Can someone explain to me how I can understand this because I have an exam tomorrow. I want to say its because -5 * -5 =25 then 25 -2 = 23 which is how they get the 23. Is this correct?
anon_nerd
  • 1,251
  • 1
  • 10
  • 16
3
votes
3 answers

Looking for a different kind of divmod function

Python's divmod function works properly, and it is almost what I want. However, its behavior with non-integer numbers needs to be slightly different for an operation that needs to be performed. When running the following code, you might see what it…
Noctis Skytower
  • 21,433
  • 16
  • 79
  • 117
3
votes
2 answers

Accurate floating point arithmetic in JavaScript

I am creating number spinner widget in JavaScript to essentially mimic the number field in webkit. When you change the number, it needs to check to see if the value is not only within the accepted range, but also that it's in step:
zzzzBov
  • 174,988
  • 54
  • 320
  • 367
2
votes
2 answers

Detect each 4 using modulus php

I am trying to detect each 4th post to insert extra code in my layout in wordpress using modulus method but I just cant get it. Here is a short example of mine:
devjs11
  • 1,898
  • 7
  • 43
  • 73
2
votes
1 answer

"-1.#IND" returned on 64-bit Windows (C++) with fmod operation when denominator is not 0

When performing the below operation: float remainder_fl = fmod (float(a), float(b)); The "remainder_fl" is set to "-1.#IND", when a = 0 and b = 300. This happens only on with a Windows release 64-bit DLL. With a debug 64-bit DLL, and with Windows…
AshD
  • 21
  • 2
2
votes
2 answers

How do I effectively use the Modulus Operator in Java

I am doing a college assignment in Java that deals with currency. For that I am advised to use ints instead of doubles and then later convert it to a dollar value when I print out the statement. Everything works fine until I do calculations on the…
Nico
  • 3,471
  • 2
  • 29
  • 40
2
votes
1 answer

Bitwise modulus computation

Given two numbers a and b where b is of form 2k where k is unknown.What would be the efficient way of computing a%b using bitwise operator.
2
votes
5 answers

What Is The Purpose of Negative Modulus Operator Results?

I was previously under the (naive) assumption that the modulus operator returned the remainder of division. I was apparently wrong, as -2 % 5 returns 3. I would have thought that 5 divides -2 zero times with -2 as the remainder. Now I understand…
Strill
  • 228
  • 3
  • 10
2
votes
2 answers

How can I insert a new table row into every other row in an existing table?

Ok I have a sqlite db, that has roughly 100 rows. It is kind of a strange thing that I'm trying to do, but I need to insert a new row between each of the existing rows. I have been trying to use the Insert statement as follows, but haven't had any…
Stephen J.
  • 3,127
  • 4
  • 20
  • 28
2
votes
3 answers

How to separate the Hex 8 bits into two 4 bits

I am using like this, $a = "002c459f"; $b = $a%10000; $c = int($a/10000); print $b; #prints 0 print $c; #prints 2 I want $b=459f; $c=002c; Can anyone suggest how will I get this?
Alexx
  • 475
  • 2
  • 8