Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

First of all, I suppose that it will be possible to make them unsigned (just like for standard types). Is this correct?

Also, what's the relationship between standard types and the new _ExtInts? Are _ExtInt(16) equivalent to shorts, or are they considered distinct and require explicit cast?

> In order to be consistent with the C Language, expressions that include a standard type will still follow integral promotion and conversion rules. All types smaller than int will be promoted, and the operation will then happen at the largest type. This can be surprising in the case where you add a short and an _ExtInt(15), where the result will be int. However, this ends up being the most consistent with the C language specification.

For instance, what if I choose to replace short by _ExtInt(16) in the above? What would be the promotion rule then?

Note that it was already possible to implement arbitrary sized ints for a size <= 64, by using bitfields (although it's possible that you could fall into UB territory in some situations, I've never used that to do modular arithmetic).

Edit: Ah, there's this notion of underlying type: one may use the nearest upper type to implement a given size, but nothing prevents to use a larger type, for instance:

struct short3_s { short value:3; };

struct longlong3_s { long long value:3; };

I don't know what the C standard says about that, but clearly these two types are not identical (sizeof will probably gives different results). What's will it be for _ExtInt? How these types will be converted?

Another idea:

what about

struct extint13_3_s {

  _ExtInt(13) value:3;
};

Will the above be possible? In other words, will it be possible to combine bitfields with this new feature?

I guess it's a much more complicated problem that it appears to be at first.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: