On Wednesday, 29 November 2017 12:03:52 PST dgutson . wrote:
> I would like to open the discussion for how to solve the portability issue
> as a standard solution. For example, by defining a new literal suffix, or a
> UDL.
> In other words, I would like to ensure that the type (and especially the
> sign) of an hexadecimal literal is fixed without depending on the integer
> size.
Why do we need anything?
int(0xFFFFFFFF);
0xFFFFFFFFU;
0xFFFFFFFFULL;
etc.
On Wednesday, 29 November 2017 12:03:52 PST dgutson . wrote:
> I would like to open the discussion for how to solve the portability issue
> as a standard solution. For example, by defining a new literal suffix, or a
> UDL.
> In other words, I would like to ensure that the type (and especially the
> sign) of an hexadecimal literal is fixed without depending on the integer
> size.
Why do we need anything?
int(0xFFFFFFFF);
0xFFFFFFFFU;
0xFFFFFFFFULL;
etc.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/35287753.28XM5GbDuN%40tjmaciei-mobl1.
On Wed, Nov 29, 2017 at 5:47 PM, Thiago Macieira <thi...@macieira.org> wrote:On Wednesday, 29 November 2017 12:03:52 PST dgutson . wrote:
> I would like to open the discussion for how to solve the portability issue
> as a standard solution. For example, by defining a new literal suffix, or a
> UDL.
> In other words, I would like to ensure that the type (and especially the
> sign) of an hexadecimal literal is fixed without depending on the integer
> size.
Why do we need anything?We may not need anything, that's why I opened the discussion :)
int(0xFFFFFFFF);This suffers the portability problem I mentioned initially: int may be smaller.
On Wednesday, November 29, 2017 at 4:19:07 PM UTC-5, dgutson wrote:On Wed, Nov 29, 2017 at 5:47 PM, Thiago Macieira <thi...@macieira.org> wrote:On Wednesday, 29 November 2017 12:03:52 PST dgutson . wrote:
> I would like to open the discussion for how to solve the portability issue
> as a standard solution. For example, by defining a new literal suffix, or a
> UDL.
> In other words, I would like to ensure that the type (and especially the
> sign) of an hexadecimal literal is fixed without depending on the integer
> size.
Why do we need anything?We may not need anything, that's why I opened the discussion :)
int(0xFFFFFFFF);This suffers the portability problem I mentioned initially: int may be smaller.Smaller than what, exactly? `int` is required by the standard to be a signed number that offers at least 32-bits of precision; MAX_INT cannot be less than 2^31-1.
The standard has guarantees about the minimum sizes of various types. So if you code against those, you're portable.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a5f2d2bc-5416-4a7c-a8b8-db8d2c651636%40isocpp.org.
On Wednesday, November 29, 2017 at 4:19:07 PM UTC-5, dgutson wrote:On Wed, Nov 29, 2017 at 5:47 PM, Thiago Macieira <thi...@macieira.org> wrote:On Wednesday, 29 November 2017 12:03:52 PST dgutson . wrote:
> I would like to open the discussion for how to solve the portability issue
> as a standard solution. For example, by defining a new literal suffix, or a
> UDL.
> In other words, I would like to ensure that the type (and especially the
> sign) of an hexadecimal literal is fixed without depending on the integer
> size.
Why do we need anything?We may not need anything, that's why I opened the discussion :)
int(0xFFFFFFFF);This suffers the portability problem I mentioned initially: int may be smaller.Smaller than what, exactly? `int` is required by the standard to be a signed number that offers at least 32-bits of precision; MAX_INT cannot be less than 2^31-1.
Use types like uint_least16_t, int_least32_t, etc when you need portability and minimal length guarantee