unsigned-long-long-int

Is std::streampos guaranteed to be unsigned long long?

自作多情 提交于 2019-11-30 07:31:51
问题 Is std::streampos guaranteed to be unsigned long long ? If not so, how does std::istream::seekg work correctly on files larger than 4G? 回答1: From http://en.cppreference.com/w/cpp/io/fpos: std::streampos is a specialization of the class template template< class State > class fpos; std::streampos is typedef'ed to be std::fpos<std::char_traits<char>::state_type> Each object of type fpos holds the byte position in the stream (typically as a private member of type std::streamoff ). From http://en

How can you easily calculate the square root of an unsigned long long in C?

断了今生、忘了曾经 提交于 2019-11-29 07:28:05
I was looking at another question ( here ) where someone was looking for a way to get the square root of a 64 bit integer in x86 assembly. This turns out to be very simple. The solution is to convert to a floating point number, calculate the sqrt and then convert back. I need to do something very similar in C however when I look into equivalents I'm getting a little stuck. I can only find a sqrt function which takes in doubles. Doubles do not have the precision to store large 64bit integers without introducing significant rounding error. Is there a common math library that I can use which has

Using long int in PHP

别说谁变了你拦得住时间么 提交于 2019-11-28 09:58:28
I am trying this out, but am unable to store large value $var = rand(100000000000000,999999999999999); echo $var; // prints a 9 digit value(largest possible) How to get a desired value ? PHP ints are typically 32 bits. Other packages provide higher-precision ints: http://php.net/manual/en/language.types.integer.php From the manual : The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18. PHP does not support unsigned integers. Integer size can be

How can you easily calculate the square root of an unsigned long long in C?

馋奶兔 提交于 2019-11-28 04:37:34
问题 I was looking at another question (here) where someone was looking for a way to get the square root of a 64 bit integer in x86 assembly. This turns out to be very simple. The solution is to convert to a floating point number, calculate the sqrt and then convert back. I need to do something very similar in C however when I look into equivalents I'm getting a little stuck. I can only find a sqrt function which takes in doubles. Doubles do not have the precision to store large 64bit integers

Getting big random numbers in C/C++

≡放荡痞女 提交于 2019-11-27 05:08:40
Standard rand() function gives numbers not big enough for me: I need unsigned long long ones. How do we get really big random numbers? I tried modifying a simple hash function but it's too big , takes too long to run and never produces numbers which are less than 1e5!! 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 integers in the range 0 to RAND_MAX and RAND_MAX is only guaranteed to be

Using long int in PHP

我们两清 提交于 2019-11-27 03:24:18
问题 I am trying this out, but am unable to store large value $var = rand(100000000000000,999999999999999); echo $var; // prints a 9 digit value(largest possible) How to get a desired value ? 回答1: PHP ints are typically 32 bits. Other packages provide higher-precision ints: http://php.net/manual/en/language.types.integer.php 回答2: From the manual: The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). 64-bit platforms

Java equivalent of unsigned long long?

我是研究僧i 提交于 2019-11-26 18:25:18
In C++, I enjoyed having access to a 64 bit unsigned integer, via unsigned long long int , or via uint64_t . Now, in Java longs are 64 bits, I know. However, they are signed. Is there an unsigned long (long) available as a Java primitive? How do I use it? Sean Bright I don't believe so. Once you want to go bigger than a signed long, I think BigInteger is the only (out of the box) way to go. Starting Java 8, there is support for unsigned long (unsigned 64 bits). The way you can use it is: Long l1 = Long.parseUnsignedLong("17916881237904312345"); To print it, you can not simply print l1, but you

Java equivalent of unsigned long long?

。_饼干妹妹 提交于 2019-11-26 06:17:31
问题 In C++, I enjoyed having access to a 64 bit unsigned integer, via unsigned long long int , or via uint64_t . Now, in Java longs are 64 bits, I know. However, they are signed. Is there an unsigned long (long) available as a Java primitive? How do I use it? 回答1: I don't believe so. Once you want to go bigger than a signed long, I think BigInteger is the only (out of the box) way to go. 回答2: Starting Java 8, there is support for unsigned long (unsigned 64 bits). The way you can use it is: Long