ondrej at svetlik.info
Tue Sep 12 09:37:48 CDT 2006
Joseph, William wrote:
> std::size_t(1) << (std::numeric_limits<std::size_t>::digits - 1)
> -----Original Message-----
> From: gtkradiant-bounces at zerowing.idsoftware.com
> [mailto:gtkradiant-bounces at zerowing.idsoftware.com] On Behalf Of Joseph,
> Sent: 12 September 2006 15:20
> To: GtkRadiant developer discussion
> Subject: RE: [Gtkradiant] [Bug 1109]
> The value also has to be a power of two - the largest representable
> power of two.
> The way you're using numeric_limits makes a (possibly safe) assumption
> that numeric_limits<size_t>::max() will be (2^n - 1). If it's not, then
> the result won't be a power of two.
> Bit-shifting is the obvious way to calculate 2^n at compile-time.
> This is the way I would do it:
> std::size_t(1) << ((sizeof(std::size_t) * 8) - 1)
> this compiles on x86:
> std::size_t(1) << 31 // 2^31
> and on x86_64:
> std::size_t(1) << 63 // 2^63
> To test that the value is correct, create a patch cyclinder. If it looks
> curved, then it's working.
Cylinder looks like a cylinder :-). Dense cylinder and very dense look
the same. Moving control points deforms it as I would expect. I'll test
it again after size_t is back.
More information about the Gtkradiant