# Divide with uint256

**URL:** <https://forum.openzeppelin.com/t/divide-with-uint256/16678>\
**Category:** Smart Contracts\
**Created:** [October 8, 2021, 7:55am UTC](https://forum.openzeppelin.com/t/divide-with-uint256/16678 "2021-10-08T07:55:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![efraim007](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/efraim007/32/8798_2.png) [@efraim007](https://forum.openzeppelin.com/u/efraim007)\
**Post date:** [October 8, 2021, 7:55am UTC](https://forum.openzeppelin.com/t/divide-with-uint256/16678/1 "2021-10-08T07:55:31Z")

</div>

I woulld like to use this code:

It is not work:

uint256 vTeamDiv= \_devFee/2; // it is for example 4  
\_rOwned[\_devWalletAddress] = \_rOwned[\_devWalletAddress].add(rDev-(rDev/vTeamDiv)

But this works:  
\_rOwned[\_devWalletAddress] = \_rOwned[\_devWalletAddress].add(rDev-(rDev/4));

what is the problem?

---

<div class="post-metadata">

**Author:** ![barakman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/barakman/32/855_2.png) [@barakman](https://forum.openzeppelin.com/u/barakman)\
**Post date:** [October 10, 2021, 1:35pm UTC](https://forum.openzeppelin.com/t/divide-with-uint256/16678/2 "2021-10-10T13:35:30Z")

</div>

Missing `);` at the end, for one.

---

<div class="post-metadata">

**Author:** ![efraim007](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/efraim007/32/8798_2.png) [@efraim007](https://forum.openzeppelin.com/u/efraim007)\
**Post date:** [October 11, 2021, 6:49am UTC](https://forum.openzeppelin.com/t/divide-with-uint256/16678/3 "2021-10-11T06:49:50Z")

</div>

Thx but it is only copy misstake :)I can solve this mathematical problem with safeMath.

---

<div class="post-metadata">

**Author:** ![frangio](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/frangio/32/15251_2.png) [@frangio](https://forum.openzeppelin.com/u/frangio)\
**Post date:** [October 14, 2021, 9:33pm UTC](https://forum.openzeppelin.com/t/divide-with-uint256/16678/4 "2021-10-14T21:33:17Z")

</div>

What do you mean it doesn't work? What error are you seeing? You need to share more details.

---

<div class="post-metadata">

**Author:** ![efraim007](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/efraim007/32/8798_2.png) [@efraim007](https://forum.openzeppelin.com/u/efraim007)\
**Post date:** [October 15, 2021, 4:31am UTC](https://forum.openzeppelin.com/t/divide-with-uint256/16678/5 "2021-10-15T04:31:58Z")

</div>

If I divide by uint256 type I can get not good result or zero result, But if I divide normaly number directly it give good result..Why? Need I divide not by uint 256? Wich variable type will good for divide?
