overflow by comparaison

Status
Not open for further replies.

maturainfankam

Newbie level 4
Joined
Aug 5, 2014
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Bremen
Visit site
Activity points
90
hi,
i have design a priority Queuing for value comparaison, the heap is always the smaller value.
1 - the value to compare are update dynamic ( with some add operation)
2 - the value to compare are represented with 16 Bit => when i update the values, we can get a overflow and the comparaison is not anymore correct.
how can i deal with these problem.
Best regards.
maturain
 

If you get an overflow then 16 bits are obviously not enough. You can use 32-bit instead.
If you only have problems with the comparison operation, copy the values to compare in 32-bit operands before performing the operation.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…