Questions tagged [multiplication]

Multiplication is the mathematical operation of scaling one number by another. It is an elementary operation of most programming languages and is typically denoted by the symbol *.

Multiplication is the mathematical operation of scaling one number by another.

It is an elementary arithmetic operation in most programming languages along with addition, subtraction, division and sometimes modulo.

It is typically denoted by * (asterisk symbol) in programming, and × (cross symbol) in math.

Example (math): multiplication of numbers 3 and 4

3 × 4 = 12

See also: Multiplication on Wikipedia

2530 questions
0
votes
0 answers

Trying to do multiplication in x86 assembly, using rax, rdi, rsi, and rcx registers

I am new to x86 assembly. I am trying to write a function for multiplication, using the rax, rdi, rsi, and rcx registers. However, I have noticed that it is not working. For 2 * 3, if I increment the right operand by 1, the result goes up by 8. And…
Caspian Ahlberg
  • 934
  • 10
  • 19
0
votes
3 answers

Multiplication in R of specific portion of a dataframe

I have a dataset from 1966 to 2002, I want change the units(multiply values by 0.305) of some of the values in the dataframe from 1967 to 1973and want the rest of the values to remain as they are. Sample Data Date A01 1 …
0
votes
1 answer

Multiplying column with increasing factor by date in Pandas

I have a dataframe with multiple columns, however in this case only three are important: Date (datetime), Country and Value. The dataframe contains time-series data which spans over multipe years. For simplicity, assume all numbers in column 'Value'…
0
votes
1 answer

How to compare various multiplication algorithms over a range of numbers

While going through a MIT lecture in MITOpencourseware (6.006 lecture 12), I came across the mention of 4 multiplication algorithms (to multiply two n-digit numbers) - Ordinary naive approach with O(n^2) complexity Karatsuba algorithm -…
Anirban Chakraborty
  • 539
  • 1
  • 5
  • 15
0
votes
5 answers

Python - Multiply table creating

Can this code be shorter in someway without importing any modules? def multiply_by2(li): new_list = [] for i in li: new_list.append(i*1) new_list.append(i*2) new_list.append(i*3) new_list.append(i*4) …
0
votes
2 answers

why is my multiplication function in haskell not letting me multiply a float?

so this is my multiplication function: multiplicacion n 1 = n multiplicacion n m = n + (multiplicacion n (m - 1)) works with integers but when attempting to multiply floats: *Main> multiplicacion 4.1 4 16.4 that works but if the second argument…
brian
  • 47
  • 1
  • 5
0
votes
1 answer

How can I multiply all the elements in a list with a given constant?

[[[-7.0, -7.0], [-7.0, -7.0], [-7.0, -7.0]], [[-7.0, -7.0], [-7.0, -7.0], [-7.0, -7.0]], [[-7.0, -7.0], [-7.0, -7.0], [-7.0, -7.0]], [[-7.0, -7.0], [-7.0, -7.0], [-7.0, -7.0]], [[-7.0, -7.0], [-7.0,-7.0], [-7.0, -7.0]], [[-7.0, -7.0], [-7.0, -7.0],…
ZR-
  • 809
  • 1
  • 4
  • 12
0
votes
1 answer

14-Complement Multiplication between 9820 and 4823

I have to multiply 9820 and 4823 in 14- Complement. I know that the result is C7A75060, but I don't know how to get there. My problem occurs when I have to multiply 8 with 4823, I get 2893A, but I know it's wrong. How do I go with this?
Angela
  • 1
0
votes
1 answer

Why am I getting a logic error in this Karatsuba Multiplication?

I've read many blogs and examples of code but I'm trying to implement the Karatsuba multiplication through a way that is currently not logically working. Only single digit number multiplications are working, but any digits longer than 1 are…
hi_it'sme
  • 49
  • 6
0
votes
1 answer

Own implementation of Karatsuba algorithm

Hi guys I am trying to come up with my own implementation of Karatsuba multiplication algorithm where the base case is trivial multiplication when one number is a single digit. My code seems to be failing to yield the correct answer and I believe…
atr1
  • 25
  • 1
  • 4
0
votes
2 answers

trouble multiplying in JavaScript

1. let inventory = [ { candy: "Twizzlers", inStock: 180, weeklyAverage: 200 }, { candy: "Sour Patch Kids", inStock: 90, weeklyAverage: 100 }, { candy: "Milk Duds", inStock: 300, weeklyAverage: 170 }, { candy: "Now and Laters", inStock:…
0
votes
1 answer

Why do I get different answers when I use math.fmod and just the mod operator? (for integers)

I write the following code to find the maximum product subarray: def ans(arr, n): M = 1000000007 cur_max = cur_min = ans = arr[0] % M for i in range(1, n): tmp = cur_max cur_max = max(arr[i], cur_min * arr[i]% M, cur_max…
0
votes
4 answers

Multiplying using recursive function C++

I did a recursive function to calculate x*y with x and y are all integers (x and y >= 0). My formula is: x * y = 0, if x is equal 0 (x >> 1)*(y << 1), if x is an even number (x >> 1)*(y << 1) + y, if x is an odd number "<<"…
Halsey
  • 119
  • 1
  • 8
0
votes
1 answer

Multidimensional tensor product in PyTorch

In pytorch I have to tensors of dimensions [K,L,M] and [M,L,N]. I want to perform a standard tensor convolution product of those tensors along the middle two dimensions to obtain a [K,N] tensor. I couldn't find official documentation on how to…
Kolya Ivankov
  • 129
  • 2
  • 11
0
votes
1 answer

Multiplication of two 64 digit number_Gettin Input Mismatch Exception

public class Karatsubamultiplication { public static void multiply(long ac , long ad, long bc, long bd, long digits) { double mul=0; mul = Math.pow(10, digits) *ac + Math.pow(10, digits/2)*(ad+bc)+bd; …
1 2 3
99
100