0
votes
1answer
23 views

(Java) How to use extended precision arithmetic to handle bigger factorials?

The Program reads in a command-line argument N, and prints N! = 1 * 2 * ... * N to standard output. public class Factorial { // return n! // precondition: n >= 0 and n <= 20 public ...
0
votes
3answers
36 views

Java: Overflow and Printing Twice

When I execute this part of my code, I get a StackOverflowError: /** * Determine the story based on the time. */ private void timeTell() { if(replay == 0){ long rndNum = ...
0
votes
2answers
41 views

Java time interval percentage with greater precision

I have the following Java code: public class Time { private Main m; private long st; private long et; public Time(Main m, long g){ this.m = m; st = System.currentTimeMillis(); ...
9
votes
4answers
111 views

Why should I use t1 - t0 < 0, not t1 < t0, when using System.nanoTime() in JAVA

When I was reading System.nanoTime() API in JAVA. I found this line: one should use t1 - t0 < 0, not t1 < t0, because of the possibility of numerical overflow. ...
1
vote
1answer
98 views

JProgressBar text overflow

My program writes text in a JProgressBar. The problem is the text is wider than the JProgressBar's width. I have already changed the JProgressBar's height to be able to write the text on two lines ...
0
votes
0answers
20 views

Is overflow over a summation applicable to double precision floating data types?

If we want to sum over a big range of numbers the fact that the data type used is a floating point double precision does it make the running sum less susceptible to overflow? Should we still some ...
0
votes
4answers
110 views

Why (int) (Math.random() * 0xFFFFFFFF) is 0

Is it due to overflow? But in my understanding, Math.random() gives a number less than 1, the result should be something less than 0xFFFFFFFF.
4
votes
6answers
100 views

How Java processes for overflow integers [duplicate]

Now signed_int max value is 2,147,483,647 i.e. 2^31 and 1 bit is sign bit, so when I run long a = 2,147,483,647 + 1; It gives a = -2,147,483,648 as answer.. This hold good. But, 24*60*60*1000*1000 = ...
1
vote
2answers
58 views

How to check for overflow from multiplication in a performant way?

Let's say I have: int result = value1 * value2; boolean isOverflow = ? How do I check for overflow in a way that's performant? I found this solution but it seems pretty expensive. I also noticed ...
2
votes
4answers
85 views

how to print a java int value when it crosses the limit

In my java code for a sort program ,(which uses my implementation of insertionsort algorithm to sort 100000 integers) ,I am trying to find out how many times the elements in the array are exchanged.I ...
6
votes
6answers
353 views

Fixing Binary search bug from Bentley's book (programming pearls: writing correct programs)

Binary search can be implemented in many ways-recursive, iterative, conditionals, etc. I took this from Bentley's book "Programming pearls: Writing correct programs" which is an iterative ...
0
votes
0answers
43 views

hornetQ ClientConsumer receive Message ,VM memory is Overflow

i have a question about HornetQ JMSBridge: i modifid the hornetQ source codes, i want to use ClientConsumer(have successful init) to get msg in the local HornetQ and use JMS producer to send msg to ...
1
vote
1answer
92 views

Java Stack Overflow when reading Object

I'm trying to load an object into Java that I had saved from a program I had made. When loading it in, Java threw a Stack Overflow Error. The object I'm loading in had about a thousand entry object ...
0
votes
3answers
68 views

Long overflows : Fibonacci series

I'm trying to solve the second Euler problem (calculate sum of all even Fibonacci numbers < 4 million) and so far I've come up with this: public class CCTrial1 { public static void fib(){ ...
-1
votes
1answer
64 views

Export a large number of data and memory overflow

I import more than one hundred data use eclipse in the computer and no problem. But when I deploy on application server it will out of memory, and I copy the local tomcat. what is this problem? The ...

15 30 50 per page