long-integer

Making 'long' 4 bytes in gcc on a 64-bit Linux machine

白昼怎懂夜的黑 提交于 2019-12-19 05:23:08
问题 I am working on porting an application to 64-bit on Linux platform. The application is currently supported on Linux, Windows, Mac 32-bit and Windows 64-bit. One of the issues we are frequently encountering is the usage of long for int and vice versa. This wasn't a problem till now since long and int are interchangeable (both are 4 bytes) in the platforms the application is currently supported on. The codebase being a huge one, with lots of legacy code with #defines for many data types, makes

Cannot implicitly convert type 'double' to 'long'

巧了我就是萌 提交于 2019-12-19 05:12:46
问题 In this code i got the above error in lines i commented. public double bigzarb(long u, long v) { double n; long x; long y; long w; long z; string[] i = textBox7.Text.Split(','); long[] nums = new long[i.Length]; for (int counter = 0; counter < i.Length; counter++) { nums[counter] = Convert.ToInt32(i[counter]); } u = nums[0]; int firstdigits = Convert.ToInt32(Math.Floor(Math.Log10(u) + 1)); v = nums[1]; int seconddigits = Convert.ToInt32(Math.Floor(Math.Log10(v) + 1)); if (firstdigits >=

Java - Can't make ProjectEuler 3 Work for a very big number (600851475143)

假装没事ソ 提交于 2019-12-19 04:52:06
问题 Resolution: It turns out there is (probably) "nothing wrong" with the code itself; it is just inefficient. If my math is correct, If I leave it running it will be done by Friday, October 14, 2011. I'll let you know! Warning: this may contain spoilers if you are trying to solve Project Euler #3. The problem says this: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Here's my attempt to solve it. I'm just starting with Java and

Python type long vs C 'long long'

故事扮演 提交于 2019-12-18 11:53:21
问题 I would like to represent a value as a 64bit signed long , such that values larger than (2**63)-1 are represented as negative, however Python long has infinite precision. Is there a 'quick' way for me to achieve this? 回答1: You could use ctypes.c_longlong: >>> from ctypes import c_longlong as ll >>> ll(2 ** 63 - 1) c_longlong(9223372036854775807L) >>> ll(2 ** 63) c_longlong(-9223372036854775808L) >>> ll(2 ** 63).value -9223372036854775808L This is really only an option if you know for sure

SQL Server - Guid VS. Long

巧了我就是萌 提交于 2019-12-18 11:44:22
问题 Up until now i've been using the C# "Guid = Guid.NewGuid();" method to generate a unique ID that can be stored as the ID field in some of my SQL Server database tables using Linq to SQL. I've been informed that for indexing reasons, using a GUID is a bad idea and that I should use an auto-incrementing Long instead. Will using a long speed up my database transactions? If so, how do I go about generating unique ID's that are of type Long? Regards, 回答1: Both have pros and cons, it depends

Fortran 90 how to write very long output lines of different length

↘锁芯ラ 提交于 2019-12-18 06:57:27
问题 I've spent hours scouring the internet for a solution to this problem and can't find anything. I have been trying to write unformatted output to a CSV output file with multiple very long lines of varying length and multiple data types. I'm trying to first write a long header that indicates the variables that will be written below, separated by commas. Then on the lines below that, I am writing the values specified in the header. However, with sequential access, the long output lines are

How can I calculate (A*B)%C for A,B,C <= 10^18, in C++?

半腔热情 提交于 2019-12-18 06:19:49
问题 For example, A=10^17, B=10^17, C=10^18. The product A*B exceeds the limit of long long int. Also, writing ((A%C)*(B%C))%C doesn't help. 回答1: Assuming you want to stay within 64-bit integer operations, you can use binary long division, which boils down to a bunch of adds and multiply by two operations. This means you also need overflow-proof versions of those operators, but those are relatively simple. Here is some Java code that assumes A and B are already positive and less than M. If not, it

Java JDK - possible lossy conversion from double to int

帅比萌擦擦* 提交于 2019-12-18 05:24:13
问题 So I have recently written the following code: import java.util.Scanner; public class TrainTicket { public static void main (String args[]) { Scanner money = new Scanner(System.in); System.out.print("Please type in the type of ticket you would like to buy.\nA. Child B. Adult C. Elder."); String type = money.next(); System.out.print("Now please type in the amount of tickets you would like to buy."); int much = money.nextInt(); int price = 0; switch (type) { case "A": price = 10; break; case "B

Java, Long.parse binary String

喜欢而已 提交于 2019-12-18 04:42:22
问题 Why does this code throw a NumberFormatException : String binStr = "1000000000000000000000000000000000000000000000000000000000000000"; System.out.println(binStr.length());// = 64 System.out.println(Long.parseLong(binStr, 2)); 回答1: 1000000000000000000000000000000000000000000000000000000000000000 is larger than Long.MAX_VALUE . See https://stackoverflow.com/a/8888969/597657 Consider using BigInteger(String val, int radix) instead. EDIT: OK, this is new for me. It appears that Integer.parseInt

Does Lua make use of 64-bit integers?

ぃ、小莉子 提交于 2019-12-18 03:43:34
问题 Does Lua make use of 64-bit integers? How do I use it? 回答1: Compile it yourself. Lua uses double-precision floating point numbers by default. However, this can be changed in the source ( luaconf.h , look for LUA_NUMBER ). 回答2: require "bit" -- Lua unsigned 64bit emulated bitwises -- Slow. But it works. function i64(v) local o = {}; o.l = v; o.h = 0; return o; end -- constructor +assign 32-bit value function i64_ax(h,l) local o = {}; o.l = l; o.h = h; return o; end -- +assign 64-bit v.as 2