division Questions
9
Solved
I have made a program that divides numbers and then returns the number, But the thing is that when it returns the number it has a decimal like this:
2.0
But I want it to give me:
2
so is there an...
6
Solved
In Java, if we divide bytes, shorts or ints, we always get an int. If one of the operands is long, we'll get long.
My question is - why does byte or short division not result in byte or short? Why...
Sauder asked 8/12, 2016 at 8:3
2
Solved
Can somebody please explain this code to me? I understand what it does but I don't understand how it works.
# >n 0 d
[->+>-[>+>>]>[+[-<+>]>+>>]<<<<...
4
Solved
I want to divide two numbers in awk, using integer division, i.e truncating the result. For example
k = 3 / 2
print k
should print 1
According to the manual,
Division; because all numbers ...
7
Solved
In Python and Ruby, signed integer division truncates towards negative infinity, and signed integer modulus has the same sign the second operand:
>>> (-41) / 3
-14
>>> (-41) % 3
...
5
Solved
I am getting references in a paper on genetic programming, to a "protected division" operation. When I google this, i get mostly papers on genetic programming and various results related to cryptog...
Erle asked 1/9, 2011 at 2:22
16
Solved
How can I multiply and divide using only bit shifting and adding?
Fabre asked 5/5, 2010 at 19:35
9
Solved
1/2
gives
0
as it should. However,
-1/2
gives
-1
, but I want it to round towards 0 (i.e. I want -1/2 to be 0), regardless of whether it's positive or negative. What is the best way to d...
Atman asked 12/11, 2013 at 1:41
6
Solved
4
I have a situation where I have invoice spreadsheets incoming with single rows that span multiple months with a quantity column containing the summation of the quantity for all months spanned.
In...
3
Solved
I remember from assembly that integer division instructions yield both the quotient and remainder. So, in python will the built-in divmod() function be better performance-wise than using the % and ...
Mirna asked 6/5, 2015 at 14:37
10
Solved
Using T-SQL and Microsoft SQL Server I would like to specify the number of decimal digits when I do a division between 2 integer numbers like:
select 1/3
That currently returns 0. I would like i...
Bentinck asked 30/7, 2012 at 9:51
4
Solved
I need to get the place value of a random number submitted by a user.
This number can by anything from 0-1000000000000000 (zero to one
trillion).
I think this can be achieved by using the JavaScri...
Whity asked 15/6, 2014 at 3:36
10
Solved
How can I ignore ZeroDivisionError and make n / 0 == 0?
4
Solved
I have a 128-bit number stored as 2 64-bit numbers ("Hi" and "Lo"). I need only to divide it by a 32-bit number. How could I do it, using the native 64-bit operations from CPU?
(Please, note that ...
Seamanlike asked 8/12, 2009 at 22:2
8
Solved
I have a big data set of floating point numbers. I iterate through them and evaluate np.log(x) for each of them.
I get
RuntimeWarning: divide by zero encountered in log
I would like to get arou...
3
Solved
I want to divide two Integers and get a BigDecimal back in Kotlin.
E.g. 3/6 = 0.500000.
I've tried some solutions, like:
val num = BigDecimal(3.div(6))
println("%.6f".format(num))
// The...
Hepato asked 9/1, 2019 at 8:56
2
Solved
Recently, I saw this question which asks how you can divide integers with ceil rounding (towards positive infinity). Unfortunately the answers either don't work for signed integers or have problems...
2
Solved
Golang's math.Mod(10, 4) returns 2 -- ie. the integer part of division result 2.5 -- but shouldn't it be "the floating point remainder", that is, 0.5?
Schwitzer asked 18/5, 2012 at 9:32
2
According to Wikipedia, the modulo operator (remainder of integer division) on n should yield a result between 0 and n-1.
This is indeed the case in python:
print(-1%5) # outputs 4
In Ruby:
pu...
Erastatus asked 19/11, 2016 at 10:53
2
Solved
I need to calculate (2128 - 1) / x. The divisor, x, is an unsigned 64-bit number. The dividend is composed of two unsigned 64-bit numbers (high and low), where both numbers are UINT64_MAX. I can on...
Temperate asked 21/11, 2021 at 4:13
6
1
I've been researching this the last few days and I have been unable to come up with an answer. I have come up with one algorithm that works if the divisor is only one word. But, if the divisor is m...
Marcus asked 8/10, 2015 at 14:39
11
Solved
Perhaps this is the wrong sort of question to ask here but I am curious. I know that many languages will simply explode and fail when asked to divide by 0, but are there any programming languages t...
Generalissimo asked 5/3, 2010 at 17:58
3
Solved
Why does this java code yield Positive Infinity?
double d = 10.0 / -0;
System.out.println(d);
if (d == Double.POSITIVE_INFINITY)
System.out.println("Positive Infinity");
else
Sy...
Trilly asked 11/9, 2021 at 4:46
1 Next >
© 2022 - 2025 — McMap. All rights reserved.