Menu
  • HOME
  • TAGS

c++ usigned long long range vs mysql unsigned bigint range

c++,mysql,bigint,unsigned-long-long-int,udf

Assuming your unsigned long long data type is 64-bit, it should fit quite well into the MySQL BIGINT UNSIGNED type, which is also 64 bits. I would suggest checking your C implementation limits.h ( or climits for C++) file for the macro ULONG_MAX to ensure it is only 64 bits....

Getting big random numbers in C/C++

c++,c,random,unsigned-long-long-int

Here's a portable C99 solution that returns a random 64-bit number: unsigned long long llrand() { unsigned long long r = 0; for (int i = 0; i < 5; ++i) { r = (r << 15) | (rand() & 0x7FFF); } return r & 0xFFFFFFFFFFFFFFFFULL; } Explanation: rand() returns...