does the following integer arithmetic property hold?
(m/n)/l == m/(n*l)
At first I thought I knew answer (does not hold), but now am not sure.
Does it hold for all numbers or only for certain conditions, i.e. n > l
?
the question pertains to computer arithmetic, namely q = n/m, q*m != n
, ignoring overflow.
Let us look at the properties of division of integers. When an integer 'x' is divided by another integer 'y', the integer 'x' is divided into 'y' number of equal parts. If 'y' divides 'x' without any remainder, then 'x' is evenly divisible by 'y'.
With the Dividing Integers Properties, you can easily simplify and answer the series of operations. Refer to various properties of the division of integers and apply them while solving the problems. Scroll to the below sections to know more details regarding the division of integer properties.
Closure Under Division Property Generally, the closure property is, if there are 2 integers, then the addition or subtraction of those integer results in an integer. But integers division does not follow closure property.
Example 2: 6 × 9 = 54 ; (–5) × (3) = −15, which are integers. Division of integers doesn’t follow the closure property, i.e. the quotient of any two integers x and y, may or may not be an integer. Example 3: (−3) ÷ (−6) = ½, is not an integer.
Case1 assume m = kn+b (b<n),
left = (m/n)/l = ((kn+b)/n)/l = (k+b/n)/l = k/l (b/n=0, because b<n)
right = (kn+b)/(n*l) = k/l + b/(n*l) = k/l (b/(n*l)=0, because b<n)
=> left = right
Case2 assume m = kn,
left = (m/n)/l = (kn/n)/l = k/l
right = kn/(n*l) = k/l
=> left = right
So, (m/n)/l == m/(n*l)
Are you talking about mathematical integers? Or fixed-width integers within a programming language?
The two equations are identical with mathematical integers, but the two functions have different overflow behaviors if you are using fixed-width integers.
For example, suppose integers are 32-bit
(1310720000/65536)/65537 = 20000/65537 = 0
However, 65536 * 65537 will overflow a 32-bit integer, and will equal 65536, so
1310720000/(65536*65537) = 1310720000/65536 = 20000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With