Bug 51458

Summary: sign extension may cause error in BitField
Product: POI Reporter: jingqi <jingqi.se>
Component: POI OverallAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P2    
Version: 3.8-dev   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: use cycle right shifting instead of just right shifting

Description jingqi 2011-07-01 09:54:57 UTC
Created attachment 27233 [details]
use cycle right shifting instead of just right shifting

the following junit test will fail,

final BitField bf1 = new BitField(0xF), bf2 = new BitField(0xF0000000);
int a = 0;
a = bf1.setValue(a, 9);
a = bf2.setValue(a, 9);
assertEquals(9, bf1.getValue(a));
assertEquals(9, bf2.getValue(a)); // fails, actually get -7

this bug haven't affected POI, just may cause error in future
Comment 1 Nick Burch 2011-07-01 16:29:26 UTC
Thanks for spotting this, patch applied (along with your unit test) in r1141977.