---
title: "In C# integer arithmetic, does a/b/c always equal a/(b*c)?"  
description: "In C# integer arithmetic, does a/b/c always equal a/(b*c)?"  
author: "Takeshi Okada"  
published: 2013-06-06  
updated: 2013-06-06  
canonical: https://www.mindstick.com/forum/1002/in-c-sharp-integer-arithmetic-does-a-b-c-always-equal-a-b-c  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# In C# integer arithmetic, does a/b/c always equal a/(b*c)?

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances),\
Let a, b and c be non-[large](https://www.mindstick.com/interview/34471/what-is-a-large-language-model-llm) positive integers. Does a/b/c always equal a/(b * c) with C# [integer](https://answers.mindstick.com/qa/113667/write-code-for-roman-to-integer) arithmetic? For me, in C# it looks like:\
**[int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql) a = 5126, b = 76, c = 14;****int x1 = a / b / c;****int x2 = a / (b * c);**\
So my [question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time) is: does **x1 == x2** for all a, b and c?\
Thanks in advance.

## Replies

### Reply by AVADHESH PATEL

Hi Takeshi,\
Let \ denote integer division (the C# / operator between two ints) and let / denote usual math division. Then, if x,y,z are positive integers and we are ignoring overflow,\
**(x \ y) \ z** **= floor(floor(x / y) / z) [1]** **= floor((x / y) / z) [2]** **= floor(x / (y * z))** **= x \ (y * z)****\**where\
a \ b = floor(a / b)\
The jump from line [1] to line [2] above is explained as follows. Suppose you have two integers a and b and a fractional number f in the range [0, 1). It is straightforward to see that\
**floor(a / b) = floor((a + f) / b) [3]****\**If in line [1] you identify a = floor(x / y), f = (x / y) - floor(x / y), and b = z, then [3] implies that [1] and [2] are equal.\
You can generalize this proof to negative integers (still ignoring overflow), but I'll leave that to the reader to keep the point simple.\
Thanks in advance.


---

Original Source: https://www.mindstick.com/forum/1002/in-c-sharp-integer-arithmetic-does-a-b-c-always-equal-a-b-c

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
