大约有 40,000 项符合查询结果(耗时:0.0110秒) [XML]
What is uint_fast32_t and why should it be used instead of the regular int and uint32_t?
...o abstract the low-level representation and make it easier to comprehend ( uint64_t instead of long long type, which is 8 bytes).
...
Replacing a 32-bit loop counter with 64-bit introduces crazy performance deviations with _mm_popcnt_
...ered a very weird effect: Changing the loop variable from unsigned to uint64_t made the performance drop by 50% on my PC.
...
Are types like uint32, int32, uint64, int64 defined in any stdlib header?
I often see source code using types like uint32, uint64 and I wonder if they should be defined by the programmer in the application code or if they are defined in a standard lib header.
...
C Macro definition to determine big endian or little endian machine?
... (aka ENDIAN_BIG_WORD) */
};
static const union { unsigned char bytes[4]; uint32_t value; } o32_host_order =
{ { 0, 1, 2, 3 } };
#define O32_HOST_ORDER (o32_host_order.value)
#endif
You would check for little endian systems via
O32_HOST_ORDER == O32_LITTLE_ENDIAN
...
How do I convert between big-endian and little-endian values in C++?
...ng(unsigned long value);
For 64 bit numbers:
unsigned __int64 _byteswap_uint64(unsigned __int64 value);
8 bit numbers (chars) don't need to be converted.
Also these are only defined for unsigned values they work for signed integers as well.
For floats and doubles it's more difficult as with p...
What integer hash function are good that accepts an integer hash key?
... which seems to be based on the blog article Better Bit Mixing (mix 13).
uint64_t hash(uint64_t x) {
x = (x ^ (x >> 30)) * UINT64_C(0xbf58476d1ce4e5b9);
x = (x ^ (x >> 27)) * UINT64_C(0x94d049bb133111eb);
x = x ^ (x >> 31);
return x;
}
For Java, use long, add L ...
How does one generate a random number in Apple's Swift language?
...
Cast the result to Int so you don't have to explicitly type your vars as UInt32 (which seems un-Swifty).
share
|
improve this answer
|
follow
|
...
How to print a int64_t type in C
...
#include <inttypes.h>
int64_t t;
printf("%" PRId64 "\n", t);
for uint64_t type:
#include <inttypes.h>
uint64_t t;
printf("%" PRIu64 "\n", t);
you can also use PRIx64 to print in hexadecimal.
cppreference.com has a full listing of available macros for all types including intptr_t ...
What is Bit Masking?
...01b
Result: 00000101b
Masking is implemented using AND, so in C we get:
uint8_t stuff(...) {
uint8_t mask = 0x0f; // 00001111b
uint8_t value = 0x55; // 01010101b
return mask & value;
}
Here is a fairly common use-case: Extracting individual bytes from a larger word. We define the ...
Best practices for circular shift (rotate) operations in C++
...dapted it to rotate by the width of the type (using fixed-width types like uint32_t).
#include <stdint.h> // for uint32_t
#include <limits.h> // for CHAR_BIT
// #define NDEBUG
#include <assert.h>
static inline uint32_t rotl32 (uint32_t n, unsigned int c)
{
const unsigned in...