Support Questions
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

## Why HexaDecimal String of any VIntWritable has 8f at the start.?

Solved Go to solution

## Why HexaDecimal String of any VIntWritable has 8f at the start.?

Explorer

I am checking some concepts in Definitive guide and could not figure out this small logic.

When you convert VIntWritable to Byte Array and convert that byte array to string, there is additional '8f' at the start of any avalue.

for eg:

for normal IntWritable the value of 172 in hexa decimal representation is - 000000ac

for VIntWritable, the HexaDecimal String for 172  is  8fac

for VIntWritable, the HexaDecimal String for -172 is  87ab

I am confused. could you please elaborate a bit.?

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: Why HexaDecimal String of any VIntWritable has 8f at the start.?

Master Guru
The first byte value is used as the sign indicator, if the number requires more than one byte to encode with.

In your specific example with 172 and -172,
1000|1111, or 8f, is used to indicate positive numbers
1000|0111, or 87, is used to indicate negative numbers

Does this help?

## Re: Why HexaDecimal String of any VIntWritable has 8f at the start.?

Master Guru
The first byte value is used as the sign indicator, if the number requires more than one byte to encode with.

In your specific example with 172 and -172,
1000|1111, or 8f, is used to indicate positive numbers
1000|0111, or 87, is used to indicate negative numbers