2,293 questions
2
votes
2
answers
212
views
Bitwise division in C : Programme seems to work for other numbers but when the divisor is 0 it returns 11 for no apparent reason
I am trying to solve the problem posed in this question which asks that division of two numbers be performed in a bitwise manner. So, I wrote the following functions.
sum() adds two numbers.
larger() ...
6
votes
1
answer
244
views
Speeding up integer division with doubles
I have a fixed-point math-heavy project and I was looking to speed up integer divisions. I tested double division with SSE4 and AVX2 and got nearly 2x speedup versus scalar integer division. I wonder ...
0
votes
2
answers
83
views
PowerShell Get-Process not working correctly when we have multiple instance of process
I am trying to record CPU and memory utilizations of processes running in my window server using PowerShell. Script is running well but I am not getting anything if Mutiple process are running with ...
0
votes
2
answers
86
views
Python 3 unit test
1st: I want to write a function "div" that takes two numbers as parameters and returns the quotient of the first number divided by the second number. and need to use a try-except statement ...
0
votes
0
answers
36
views
Setting Long as result of division between Longs yields Integer [duplicate]
Suppose I have the following code within a VBA script:
Dim Start As Long
Dim Final As Long
Dim Rate As Long
Start = 10
End = 9
Rate = Final / Start
MsgBox("Rate Variable = " + CStr(Rate) + ...
0
votes
1
answer
59
views
Knuth MIX division example
I was having trouble following an example in The Art of Computer Programming, (3rd Ed.) by Donald Knuth. I figured it out by starting to ask here ("explain it to a duck"), so I thought I ...
4
votes
1
answer
136
views
How to divide two NUMERIC values and get a result that has the maximum number of digits the NUMERIC type supports?
The documentation of the NUMERIC type states:
Specifying: NUMERIC without any precision or scale creates an “unconstrained numeric” column in which numeric values of any length can be stored, up to ...
4
votes
0
answers
148
views
How does a fast integer division algorithm for a constant divisor with rounding up/down work (or *not* work)?
I'm currently focusing on the implementation of Kyber (ML-KEM).
I noticed that the AVX2 version of the compress operation seems to use a fast division algorithm.
In the compress operation, we need to ...
1
vote
0
answers
65
views
How to evenly divide a total value into predefined values with buffers in Python?
I've been working on a fence calculation tool that breaks down a total length, as equally as possible, into components (rails and posts) using a predefined set of rail lengths. The user can choose a ...
0
votes
1
answer
89
views
How do you make sure a random integer is divisible by another random number in a math game [duplicate]
I am making a game in Python where you answer math questions. I have added 3 operations: addition, subtraction and multiplication. They have 5 modes, each harder than the other.
Now I want to add ...
1
vote
1
answer
159
views
Working with 64-bit products and quotients of 32-bit integers in assembly x86-64
Starting to learn assembly x86-64, I'm writing a program that gets an array of integers and does some calculations on it. The purpose isn't relevant to the question, but the calculations include ...
2
votes
0
answers
82
views
How does this assembly code perform the source code b = a/3 when a = 2? [duplicate]
I'm trying to trace this C source code (when a = 2):
b = a/3;
To this ARM assembly code (for unsigned 1 byte value):
ldrb r2, [fp, #-6] @ zero_extendqisi2 @ tmp162, a
ldr r3, .L34 @ tmp164,
...
-2
votes
1
answer
158
views
why division doesn't work with #define numbers? [duplicate]
#define BLUR 2
#define LEN (2 * BLUR + 1) * (2 * BLUR + 1)
using namespace std;
int main()
{
cout << 50 / LEN; // result is 50
}
the expected result is 2 but it's 50. I try another numbers ...
-2
votes
1
answer
44
views
how can i get point from user's input amount in php
i'm new to php. please i would want to get figure from user's input amount such as if a user pays 2500 i want to get 2.5 from the amount he inputed examples below
1000 ------ 1 ,
1500 ------...
0
votes
2
answers
258
views
How to test if a BigDecimal object is divisible by another BigDecimal in Java?
I'm working on a problem from a Java textbook which asks to find the first 10 numbers with 50 decimal digits that are divisible by 2 or 3. Here is my code:
import java.math.*;
public class Divisible {...