Carl Pettersson

Ranch Hand
+ Follow
since Sep 09, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Carl Pettersson

Originally posted by Ilja Preuss:


But mathematically, it is, isn't it?


Yes, and no.
1.1 equals 1.100, but 1.100 has better precision than 1.1. This can be illustrated by this example: 1.100 rounded to two digits is 1.1, but so is 1.109, 1.14 etc.
So 1.1 really is only precise to say that it is a number N 1.15<N<=1.05, while with 1.100 is 1.150<N<=1.050.

But of course, this doesn't matter much to a computer.
15 years ago
The warning means what it says: You are using a API, or resource, (class/interface etc) that is marked as 'old', or deprecated. This doesn't mean that it won't work, just that it is not the recommended way any more.
The suggestion of compiling with Xlint is good, you do it like this:

Now javac will tell you more about which API it considers old. Mostly (if not always?), the java specification documents (http://java.sun.com/reference/api/index.html) will give hints on what you should use instead of the old way.
Hope this helps.

(Gah, stupid smilies... )
[ July 14, 2008: Message edited by: Carl Pettersson ]
15 years ago
Supposing you need to use Java to do it... A line break is represented as the character combination '\n', so if you were to remove these from the text it'd be a single line, right?
Have you written any code that attempts to do this? Can we see it?
15 years ago
The exception indicates that you do not have permission to use the printer... What user are you running the program as, and which privileges does the printer require? Can you print documents outside of your java program?
15 years ago
It is never too late to be stupid... I've been misreading my output for a few hours straight now About time I call it a day I think. Sorry for any wasted effort...
15 years ago
I'm having trouble getting good results with quite simple calculations with Math.log10. For instance, I get Math.log10(16)/Math.log10(2)=3.906890595..., but I should get 4.0... Why is this? I'm not doing anything fancy at all, just

to do a base conversion...
I'm using JDK1.6.0_05-b13 on SunOS(sparc SUNW,ultra-4)
[ July 03, 2008: Message edited by: Carl Pettersson ]
15 years ago
I've had a look at it (read the manual), and it seems rather more complicated than I'd hoped. I'll try it though, but any ideas on my approach are still very welcome!
15 years ago
Something like

Should do what you want, right?
15 years ago
Also, the reason the first comparison (s1==s2) returns false is that the == operator will, when used on objects, check if s1 and s2 are the same object. That is, if they are really references to the same memory area.
Had you written like this:

Then s1==s2 would have been true.
15 years ago
Hello all!
I'm writing a parser to generate JUnit-like files from a custom test format used in one of our products. The product is not writted in Java, so we cannot rewrite the tests to JUnit, but our build statistics tool only reads JUnit-format.
What I'd like some help with is evaluating if I'm doing this in a smart way, or if you can suggest a better one. Below is my current idea.
The files generated by our test tool look like this (part of acual output):

So each line is date, time, log severity, test facility and status message.
The approach I'm currently using reads the input into an arraylist of hashmaps, and removes header/footer and other "uninteresting" lines.
Then I iterate over the ArrayList, and depending on what is in the status field, I do different things.
However, I'm finding this increasingly difficult. The test is started with a line with a status "Test: <TESTNAME>...", then any output during the test, and then "Test: <TESTNAME> [ <TEST OUTCOME> ] ( <FAILED/TOTAL> )".
So I'd have to save a temporary var with the current test name, collect any lines in another temporary var, until I find the test name again.
Is this really a good strategy?
Also, is the JUnit-XML format specified somewhere? I've googled but haven't found anything. Since there are multiple Script-sections, I thought I'd create a separate <testsuite>, and thus file, for each. However, there are sometimes nested Scripts, how would you handle this?

Best regards
Carl Pettersson
[ July 03, 2008: Message edited by: Carl Pettersson ]
15 years ago
Odd... Changing the method name made it work.
18 years ago
BigInteger.valueOf(2) returns an BigInteger with the value 2. So, you declare two to be a BigInteger with the value 2.
Multiply() also returns the result of the operation, so you do

After this, myBigInt is a BigInteger with value 4, since you added it to itself, and 2 + 2 = 4.
Same goes for the other, such as BigInteger.multiply().
18 years ago
I am getting an UnsatisfiedLinkError at runtime, and I can't understand why. Class FS2 begins with

FS2.h declares the native method like this:

And the function is implemented with a copy/paste, and compiled to FS2CFunk.dll.

The only idea I can come up with is the return type causing problems... I declare the array to be returned with
int *itArray = new int[scrX * scrY];
and then return it by casting
return (jintArray)*itArray;

Ideas?
18 years ago
I've done a bit of fractal drawing using the BufferedImage method setRGB(), doing and after the iteration is done draw it onscreen with Graphics.drawImage().
18 years ago

Originally posted by Ilja Preuss:
Moving declarations of local variables inside a method typically doesn't have any effect on the byte code. If you meant something else, I'd advise to try it...


I meant as in making the variable a class variable like this

I thought it should be faster, since I don't really need to declare new variables for each iteration. Somewhere through moving variable declarations outside of methods to try it out, I did something wrong, and render time went up by 500% Can't figure out what it is, tried moving everything back in, but that didn't help anything...
18 years ago