gh9
gh9

Reputation: 10703

Reading byte arrays

I am reading async file i/o. When writing to a file microsoft sets the bufferSize to 4096 bytes, but when reading they are using [0x1000]. I understand that this evaulates out to a 4k block just like seting the bufferSize to 4096. My question is why would they use the Hex Value instead of an integer?

Upvotes: 2

Views: 803

Answers (1)

Neil
Neil

Reputation: 5780

From a practical standpoint, there is no difference. They are the same value essentially. However, as you probably know, computers tend to deal better with powers of two. 0x1000 just tends to render the idea more clearly than 4096.

This is the same reason why you would assign flags values using hexadecimal rather than their decimal values. It makes it clear to the reader that its value is not a coincidentally clean number in hexadecimal but deliberate. That said, don't use hexadecimal when it is completely irrelevant.

int numberOfCats = 0xA7;

Hope that helps!

Upvotes: 4

Related Questions