# How to do signed operations on intbv

**URL:** <https://discourse.myhdl.org/t/how-to-do-signed-operations-on-intbv/419>\
**Category:** Support\
**Created:** [March 17, 2020, 11:39am UTC](https://discourse.myhdl.org/t/how-to-do-signed-operations-on-intbv/419 "2020-03-17T11:39:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![josyb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.myhdl.org/josyb/32/5_2.png) [@josyb](https://discourse.myhdl.org/u/josyb)\
**Post date:** [March 17, 2020, 8:54pm UTC](https://discourse.myhdl.org/t/how-to-do-signed-operations-on-intbv/419/2 "2020-03-17T20:54:58Z")

</div>

I guess you have declared your accumulator as `Signal(intbv(0)[8:])`  
This implies that only positive values can be assigned to this signal.  
In order to allow for negative values you need to declare it this way: `Signal(intbv(0, min=-128, max=128))`  
This may not the effective solution for an 8-bit accumulator as you probably also want to accommodate 8-bit unsigned values. So it is better to resolve this by using unsigned two’s arithmetic and declaring the accumulator as `Signal(modbv(0)[8:])` and work with this.  
I hope this sets you on your way.

Regards,  
Josy

---

_[View the full topic](https://discourse.myhdl.org/t/how-to-do-signed-operations-on-intbv/419)._
