Questions tagged [long-integer]

A long integer is an integer number, typically twice the size of a standard integer. It is represented by the keyword 'long' in several programming languages.

A long integer is an integer number, typically twice the size of a standard integer. It is represented by the keyword 'long' in several programming languages.

http://en.wikipedia.org/wiki/Integer_(computer_science)#Long_integer

2408 questions
0
votes
2 answers

Why pow function is giving error while dealing with long long int?

#include using namespace std; #define ll long long int bool check(ll num) { ll temp=num; ll sum=0; while(num!=0) { ll rem=num%10; sum+=pow(rem,3); num/=10; } if(sum==temp) …
0
votes
1 answer

Convert double to long such that it equals increments from zero

Does there exist, or can you create, a fast method A() which converts a double to a long such that: A(0d) = 0L A(Math.nextUp(0d)) = 1L A(Math.nextUp(Math.nextUp(0d))) = 2L A(Math.nextUp(Math.nextUp(Math.nextUp(0d)))) = 3L ... A(Double.MAX_VALUE) =…
Runekn
  • 85
  • 5
0
votes
1 answer

Java most efficient way using a long epoch timestamp to detect a change in day

Problem situation: I have an incredibly high number of records all marked with a timestamp. I'm looping through all of them to do this and that but I need to detect when the day has changed. Right now for each loop I'm…
macmeyers50
  • 309
  • 2
  • 15
0
votes
1 answer

Strange Python 3 mod behavior for longs

Consider this code snippet. >>> n, m = 10011617, 100000000000006340 >>> s = lambda n: n * (n + 1) / 2 >>> s(n) 50116242483153.0 >>> s(n) == int(s(n)) True >>> m % s(n) 18096246116101.0 >>> m % int(s(n)) 18096246116105 As you can see, s(n) is an…
Daniel
  • 3,188
  • 14
  • 34
0
votes
2 answers

What is the largest prime factor of the number 600851475143(Java)? What could be my mistake?

The code works just fine for the int data type, but 600851475143 seems to be too big of a number. How can I make it work? It just keeps running and never gives me an answer. public class Main { public static void main(String[] args) { …
Vasila_M
  • 53
  • 6
0
votes
1 answer

Slow mysql query--2 hours+

Hello this is my query and is taking around an hour to complete. The table is 7 million records in innodb. I have an index on (timeStamp,symbol). Test7() is a function for coming up with previous week day. I am using mysql 5.3. Any suggestions on…
0
votes
0 answers

C program takes an absurdly long amount of time (or enters infinite loop)

The function is given a string (for example "communism") and checks whether or not its suffix is a part of a wordbank - the program takes an absurdly long time (or is infinite-looped, I don't know but I suspect the first). here's an example of the…
kal_elk122
  • 143
  • 6
0
votes
2 answers

How make a value being changed as long as a button is being pressed

I have an initial value CamTimeObsVar = 50 and I want make it reducing as long as button btnCamTimeL is being pressed. When I release the button to stop reducing. I tried the following code but the variable reduced only once. Is it possible to…
Psiloritis
  • 17
  • 5
0
votes
3 answers

Any datatype for integers longer than a Long?

I want to convert binary to an integer, multiply it by 17, then convert it back to binary. This is my code: Scanner scan = new Scanner(System.in); String n = scan.nextLine(); long j = Long.parseLong(n, 2); j = j *…
Julie P
  • 19
  • 4
0
votes
0 answers

Difference between defining macro and "using" in c++

So I was recently looking at competitive programming, and many people have the following code in their program to make it faster to type: #define ll long long For every instance of ll, long long will be replaced. However, I also saw another similar…
0
votes
3 answers

Why can't I print an unsigned int with printf in C?

For a school project, I'm trying to re-create the printf function of the stdio.h library in C. I'm currently working on getting the unsigned int printing part working, but for some reason, why I try the real printf to print an unsigned int, it gives…
Max
  • 7
  • 3
0
votes
2 answers

Cannot declare any signed Integer types in C#

I'm working on an ASP.NET application in Visual Studio 2019. I'm running into a problem I've never encountered with C# before. I seemingly cannot declare any integer types other than UInt64. Trying to declare an Int64 or a long gives me errors,…
0
votes
1 answer

Kotlin: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer

I know there are a lot of questions about this exception but no answer suited my case. var count = sharedPref.getInt("flutter.badgeCount", 0) // line 12 ShortcutBadger.applyCount(applicationContext, count+1) // line 13 count should be an…
Fabio
  • 376
  • 6
  • 19
0
votes
1 answer

Most efficient way to convert Long to string?

If I have a Long (not the primitive) whats the best way to convert it to a string. By best, I mean fastest. Currently, I'm doing this. Long testLong = 123456L; return new StringBuilder() .append(PREFIX) .append("_") …
user12530264
0
votes
1 answer

Merge/multiply elements in Array using linear recursion

I must implement a recursive method merge(long[] arr, int i) which multiplies adjacent elements if they have the same value, starting at index i. Example: merge({1, 2, 2, 4}, 0) should produce an array like this: {1, 4, 4} If there are multiple…
Nils
  • 1,755
  • 3
  • 13
  • 25