Tag: division

62 votes
5 answers
2.5K views
Why does GCC use multiplication by a strange number in implementing integer division?

I've been reading about div and mul assembly operations, and I decided to see them in action by writing a

avatar
Xavier
0 1 0 9
asked 07 September, 2021
63 votes
6 answers
1.9K views
What is the behavior of integer division?

For example, int result; result = 125/100; or result = 43/100; Will result always be the floor of the

avatar
Hallie
0 1 0 9
asked 07 September, 2021
62 votes
7 answers
941 views
Why is division in Ruby returning an integer instead of decimal value?

For example: 9 / 5 #=> 1 but I expected 1.8. How can I get the correct decimal (non-integer) result? Wh

avatar
Robt
0 1 0 9
asked 07 September, 2021
66 votes
16 answers
2.9K views
What is the difference between '/' and '//' when used for division?

Is there a benefit to using one over the other? In Python 2, they both seem to return the same results: >&

avatar
Thurman
0 1 0 9
asked 07 September, 2021
56 votes
30 answers
793 views
Divide a number by 3 without using *, /, +, -, % operators

How would you divide a number by 3 without using *, /, +, -, %, operators? The number may be signed or unsig

avatar
Bryant
0 1 0 9
asked 07 September, 2021
52 votes
18 answers
1.7K views
How to perform an integer division, and separately get the remainder, in JavaScript?

In JavaScript, how do I get: The whole number of times a given integer goes into another? The remainder?

avatar
Dusty
0 1 0 9
asked 07 September, 2021