According to Google Calculator (-13) % 64 is 51.  According to Javascript (see this JSBin) it is -13.  How do I fix this?...
How do I figure out if a variable is divisible by 2? Furthermore I need do a function if it is and do a different function if it is not....
My problem is to compute (g^x) mod p quickly in JavaScript, where ^ is exponentiation, mod is the modulo operation. All inputs are nonnegative integers, x has about 256 bits, and p is a prime number of 2048 bits, and g may have up to 2048 bits.  Most...
I try to calculate with JS' modulo function, but don't get the right result (which should be 1). Here is a hardcoded piece of code.  var checkSum = 210501700012345678131468; alert(checkSum % 97);  Result: 66   Whats the problem here?  Regards...
For a homework assignment, I need to return the remainder after dividing num1 by num2 WITHOUT using the built-in modulo (%) operator.  I'm able to get most tests to pass with the following code, but I'm stuck on how to account for -/+ signs o...
I'm trying to iterate over an array of jQuery objects, by incrementing or decrementing by 1. So, for the decrementing part, I use this code:  var splitted_id = currentDiv.attr('id').split('_'); var indexOfDivToGo = parseInt(splitt...
I was wondering how JavaScript handles modulo. For example, what would JavaScript evaluate 47 % 8 as? I can’t seem to find any documentation on it, and my skills on modulo aren’t the best....
Consider following code sample:  import javax.script.ScriptEngine; import javax.script.ScriptEngineManager;  public class Tester {    public static void main( String[] args ) throws Exception {       ScriptEngine se = new ScriptEngineManager().getEng...
I was testing out how splice works while iterating through an array, and don't understand why 0 stayed in the list?  var array = [2, 5, 9, 14, 0, 1, 3, 6, 7]; for (var i = 0; i < array.length; i++) {      if (array[i]%2 == 0) {          array....
Some time ago I've seen somewhere a trick to perform modulo operation using bit operators. But now I cannot in any way perform proper operation. Anyone knows how to do it ? From what I remember it was faster than using %....

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.