Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 2/2
1.0
Is this intended? I strongly remember earlier versions returning int/int=int? What should I do, is there a new division operator or must I always cast?
...
What does the /= operator in C# do and when is it used?
...
from Wikipedia: fourier division.
Here is a screenshot of the same:
(view in full-resolution)
What is the logic behind this algorithm?
I know it can be used to divide very large numbers, but how exactly does it work?
...
I am currently working with a sparc computer and I am trying to know if a number is prime or not.
here is a part of the code :
mov 0,%y
mov 3, %l1
nop
nop
nop
sdiv %l1,2,%l3
rd %y, %l6
cmp %l6, 0
So basicaly what we have here is 3/2. So there should be a reminder of 1. This r...
I saw this in someone's code:
y = img_index // num_images
where img_index is a running index and num_images is 3.
when I mess around with '//' in ipython, it seems to act just like a division sign (i.e. one forward slash). I was just wondering if there is any reason for having double forward slashes?
Thanks all!
...
I have tried to look online for a way to do a non-restoring division, but the explanation has still left me quite clueless.
dividend = 0100 0011 1100 0000
quotient = 0110 0010
divisor is not given
How do you figure out the total # of operations (ie. the number of subtractions, the number of additions performed)?
...
I was writing this code in C when I encountered the following problem.
#include <stdio.h>
int main()
{
int i=2;
int j=3;
int k,l;
float a,b;
k=i/j*j;
l=j/i*i;
a=i/j*j;
b=j/i*i;
printf("%d %d %f %f\n",k,l,a,b);
return 0;
}
Can anyone tell me why the code is returning zero for the first and third variables ...
Here is the code I'm using in the example:
PRINT @set1
PRINT @set2
SET @weight= @set1 / @set2;
PRINT @weight
Here is the result:
47
638
0
I would like to know why it's returning 0 instead of 0,073667712
...
I am doing very simple int division and I am getting odd results.
This code prints 2 as expected:
public static void main(String[] args) {
int i = 200;
int hundNum = i / 100;
System.out.println(hundNum);
}
This code prints 1 as not expected:
public static void main(String[] args) {
int i = 0200;
int hundNum = i /...
>>> sum((1, 2, 3, 4, 5, 6, 7))
28
>>> 28/7
4.0
>>> sum((1,2,3,4,5,6,7,8,9,10,11,12,13,14))
105
>>> 105/7
15.0
>>>
How do I automate this sum and division using a loop maybe?
Edit: Maybe I wasn't clear - I want a loop to keep doing the sum (of multiples of 7, eg 1-7, 1-14, 1-21 etc..) until it reaches x (x is the user input)
Okay, fig...
I need some division algorithm which can handle big integers (128-bit).
I've already asked how to do it via bit shifting operators. However, my current implementation seems to ask for a better approach
Basically, I store numbers as two long long unsigned int's in the format
A * 2 ^ 64 + B with B < 2 ^ 64.
This number is divisible by 2...
I'm having an issue I want to learn more about, and how to avoid. I've got this code
len :: (Num r ) => [a] -> r
len [] = 0
len xs = 1 + len ( tail xs )
avg :: (Num t) => [t] -> Double
avg xs = ( sum xs ) / ( len xs )
Which renders the following error
len.hs:6:9:
Couldn't match expected type `Double' against inferred type `t'
...
I have written an interpreter that requires me to perform 32-bit division of unsigned integers. In Java, I can do this as:
reg[a] = (int) ((reg[b] & 0xFFFFFFFFL) / (reg[c] & 0xFFFFFFFFL));
But I would like to avoid the conversion to long and back to int. Java already gives the unsigned right shift operator >>> for that special case, s...
Is there a faster way of dividing by 2, with sign, in assembly than the one in the example below?
...
mov ecx, 2
idiv ecx
push eax #push the result
...
...
I need to write an accounting routine for a program I am building that will give me an even division of a decimal by an integer. So that for example:
$143.13 / 5 =
28.62
28.62
28.63
28.63
28.63
I have seen the article here: http://stackoverflow.com/questions/577427/evenly-divide-in-c, but it seems like it only works for integer divis...
This is extremely slow:
try
{
x = k / y;
}
catch (DivideByZeroException) { }
This is about 5x faster:
if (y > 0) x = k / y;
Can anybody tell me why?
...
hi,
i was once supposed to make a short assembler code for dividing with numbers that are not power of 2. My solution was subtracting the divider in cycles and the number of cycles was the actual result. Is there anything faster? What's the usual way to sort this out?
...
Possible Duplicate:
Python float - str - float weirdness
In python, 2/5.0 or 2/float(5) returns 0.40000000000000002
Why do I get that error at the end and how can I get the right value to use in additional calculations?
...
Okay. I have been bashing my head against the wall for like 2 hours now trying to figure out why in the world double answer = 364/365; is telling me that answer is 0. Or any other combination of double for that matter, its just truncating the decimal and I just don't know why. Please help!!!
...
I'm messing around with writing a class similar to mpz (C) or BigInteger (Java). This is just for fun, so please don't go on about how I shouldn't be writing my own.
I have a class similar to:
public class HugeInt
{
public List<Integer> digits;
public HugeInt(String value)
{
// convert string value into its sepera...