2,292 questions
2
votes
2
answers
227
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
267
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
105
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
96
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
39
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
70
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
165
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
157
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
71
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
97
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
173
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
90
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
176
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
57
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
274
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 {...
0
votes
0
answers
104
views
Division function for binary numbers. Python
Hello everyone!
I am a beginner writing a simple program that performs four arithmetic functions between binary numbers. Writing functions, addition, subtraction and multiplication, there were no ...
0
votes
1
answer
63
views
Any faster way to do this operation which loops for 16k times in c/c++
This code reduces a unsigned 32 bit integer into a 8bit as per our requirement.
Currently this operation takes almost 2.1 mili sec to complete. Can it be optimized to complete at least under 0.9 mili ...
4
votes
2
answers
159
views
Handling division of double by a large power of 2 in C++
My question is about how division should be handled when you have to divide with a large power of 2, which is likely to trivial thing but I didn't find any helpful material. I am basically asking ...
0
votes
1
answer
83
views
Create an array of div_t type structure elements in C++
I have a structure (this is kinda irrelevant for my question), and in this structure, a DATE type is used.
typedef div_t DATE;
#define ans quot /* (s)(l)div_t : .quot -> .ans... */
#...
0
votes
0
answers
81
views
How to divide float number by integer in assembly x64
mov eax,5
for: ;(future tag for loop)
call Putere
movsd xmm2,xmm1
div xmm2,eax
movsd xmm0,xmm2
xmm1 correctly calculates a variable x raised to the power of eax. eax will be the index for a loop and ...
0
votes
2
answers
49
views
Calculating simple returns (one cell divided by cell above it in same column, result in another column) across large sets of data, google sheets
I'm trying to find a way to automate a simple return calculation (one cell divided by cell above it) across a large set of data which updates/adds cells regularly without having to pull-down the ...
0
votes
1
answer
44
views
How to check the Rest in a Floating point division in MIPS?
i'm trying to make a division for 2 in MIPS, (i'm using PCSPIM).
basically i have a number in a register ($f0), loaded.
after some operations, i would like to divide this number for 2, and check if ...
0
votes
2
answers
84
views
Algorithm to split integer into groups of defined smaller integers
I want to write a function that when given an integer, can partition it into groups of specified smaller integers.
Specifically, the passed in value needs to be split into a set of values of where ...
1
vote
1
answer
1k
views
Restoring division algorithm in Risc V
I wanted to implement the restoring division algorithm (without using the div operation) in RISCV assembly language.
The algorithm I have to implement is the following
.
I implemented this, but it is ...
0
votes
1
answer
59
views
Evaluating this in Assembly (A % B) % (C % D)
INCLUDE Irvine32.inc
INCLUDELIB Irvine32.lib
INCLUDELIB kernel32.lib
INCLUDELIB user32.lib
.data
A SBYTE 10d ; A is an 8-bit signed integer
B SBYTE 2d ; B is an 8-bit signed integer
cc ...
3
votes
1
answer
327
views
Why don't x86-64 (or other architectures) implement division by 10?
I'm familiar with compilers replacing division and modulo by a constant (e.g. x/10) with multiplication by a magic number (x * 0xcccccccd) >> (32 + 3). Compiler example here.
movl $...
0
votes
3
answers
722
views
SVG: How to Divide a Circle into Equal Segments of 12
ignor the barI have been experimenting with SVG recently and to be more specific on creating a 12-part wheel.I came across a code snippet in a previous post that fit my needs but consists of 6 parts ...
-2
votes
1
answer
303
views
Fast Division C++ [closed]
I'm working on a scientific computing project that requires arbitrary precision for any real number. The way I am representing the real number approximations as two dynamic arrays of uint64_t. Each ...
-3
votes
4
answers
273
views
How to divide a nonnegative variable integer by a constant fixed-point rational ≥1 without overflow (at all, if possible)?
How to compute ⌊𝑥÷𝑐⌋ for a variable integer 𝑥 and a fixed-point rational number 𝑐≥1 precisely? The input 𝑥 ∈ [0, INT_MAX] is stored in a variable of type int, 𝑐 ∈ [1, INT_MAX] is given as a ...
0
votes
0
answers
50
views
Converting a large Bit List to a decimal string in Java
I have an assigment in which i have implemented a BinaryNumber class that has a BitList that represented the binary number as lsb first.
I now want to implement a function that prints the decimal ...
1
vote
1
answer
175
views
Issue with div in NASM
I am learning basic assembly using NASM and stumbled on an issue in the div of two numbers.
Here is the code I wrote:
section .data
msg1 db "Enter first digit (a): ", 0
len1 equ $- ...
1
vote
1
answer
1k
views
Fast computation of squared norm and normalized vector with Eigen
I have a section of my code that needs to run millions of times. It seems that the most costly part of it is this computation:
Vector2d directedInverseSquare(Vector2d &pos1, Vector2d &pos2) {
...
0
votes
1
answer
159
views
Implementation of the binary division in C [closed]
Here is the code which implements binary division: Here is the function where I print the final number at the end.
On Windows I get the correct answer: 60000000 7948AECA D269AE4A 6B41DD10 64209812 ...
0
votes
0
answers
50
views
How Do I Avoid np.where Calculating Divisions By Zero? [duplicate]
Results = np.where(
thing_minus_1 == 1,
0,
(1 - thing) / (1 - thing_minus_1),
)
Running this code causes a warning:
RuntimeWarning: invalid value encountered in divide
This is because it ...
0
votes
1
answer
84
views
C++ Code Issues: Partial Execution and Unexpected Results
I have a problem, I have this code and when I run it, the code starts and tells me to enter numbers, but when I enter them, nothing happens
the code is supposed to show me the elements that divided by ...
0
votes
1
answer
120
views
Best way to find divisors of a number [duplicate]
I have a function that finds the prime divisors of a number and returns a list of its prime factors:
def prime_factors(n, listFact=[]):
end = floor(sqrt(n))
if n == 1:
return listFact
...
0
votes
1
answer
84
views
My Rectangle Subdivision Algorithm Skips Half of the Vertical Pixels
I am working on making a rectangle subdivision algorithm for usage with a search tree. However, the rectangles seem to "skip" every one or two vertical pixels, leaving a lot of null space.
...
1
vote
1
answer
102
views
How do I annotate a division with the numerator and denominator vertically aligned and separated by a horizontal line
I'm currently trying to add an annotation to my ggplot which displays the fraction 1/9 in the specific format shown in the image I've provided. Despite it seeming like a straightforward task, I find ...
0
votes
1
answer
120
views
Dividing some columns in Pandas Dataframe with Stock values with a Variable. First Column is DatetimeArray [duplicate]
Original Question:
I have downloaded Stock data with yfinance for quite a while where I add the latest data to a previous csv file not to download all data every time.
As a Stock split disturb my ...
0
votes
0
answers
33
views
How to "create a Div that does NOT start on a new line, after a header?" [duplicate]
I'm relatively new here and I feel like the solution is so simple that I am just not seeing it.
#GeneralTextBox02{
background: #ddd;
display: inline-block;
height: 100px;
...
0
votes
1
answer
52
views
how to use division-class for image in html css?
I am learning coding...newbie.
in html: case1 I created a class inside div
` <div class="image">
<img src="./.../imageabc.jpg" alt="abc photo"/>
</div>`
...
0
votes
2
answers
226
views
Verilog - division with negative numbers
module test;
reg [3:0]a;
initial
begin
a= -4'b1100 / 6;
$display(a);
end
endmodule
Why is the output 8?
I tried this code in EDA playground and I ...
1
vote
0
answers
187
views
How to perform float division on two usize types in Zig [duplicate]
In my CS class I am learning about hash sets and I am trying to learn Zig at the same time. I'm trying to create my own HashSet class that can hash strings, add them to an index of an array, and ...
0
votes
2
answers
68
views
numeric column operation in r with condition from another factor level
Given the dataset df
df<-structure(list(status = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), levels = c("healthy",
"rotten"...
1
vote
1
answer
457
views
How to add SUBTOTAL to SUMPRODUCT with division formular in Excel?
Below are some raw data with related formular:
Col A1, A2 & A3: 4, 6 & 12
Col B1, B2 & B3: 100, 150 & 120
Formular: = SUMPRODUCT(B1:B3/A1:A3)
I tried to add SUBTOTAL function in ...
1
vote
1
answer
32
views
Extracting summary from selected records as a division of values
Input table is like this:
Year
Region
ID
Value
2021
Asia
01
15
2021
Europe
02
35
2021
Asia
03
45
2022
Europe
04
49
I'm selecting entries by the year, region and id:
SELECT year,
region,
...
0
votes
1
answer
147
views
Why element wise division between two dataframes with one column each result in NaN and two columns?
import pandas as pd
df0 = pd.DataFrame({'a': [864371.0, 864383.0, 864364.0, 864381.0, 864364.0]})
df1 = pd.DataFrame({'b': [867318.0, 867315.0, 867323.0, 867331.0, 867327.0]})
df0/df1
a b
0 ...
0
votes
1
answer
171
views
One-Step Equations
what is -2.4=z/-4
The division sign is meant to be a fraction. I tryed this equation on my calculator and I just cannot find the answer and this assignment is due tomorrow. Please someone help me. I ...
0
votes
1
answer
211
views
Division of large sums; deal with summation up to infinity
I'm running an algorithm which generates pairs (t[i], x[i]), where both t[i] and x[i] are positive doubles. They are not independent; (t[i], x[i]) depends on (t[i-1], x[i-1]). Once the algorithm has ...
1
vote
2
answers
56
views
This is a currency converter app . Why cant i divide it?
im trying to divide a number by 23 in flutter
I expected to directly get a number back but instead i got this error
The operator '/' isn't defined for the type 'String'.
Try defining the operator '/'....