StringBuffer problem

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

StringBuffer problem

Postby vladra » Thu Nov 29, 2007 4:28 pm

This code doesn't work properly. A code after sb.append never be executed when i==0.

Code: Select all
StringBuffer sb = new StringBuffer(20);
int i = 0;
sb.append(i);


Infinite loop (?) occurs when StringBuffer.append calls Math.log.

What about Math.log I don't know. I think it's necessary to add the following code at the top of StringBuffer.append:

Code: Select all
public StringBuffer append (int aInt)
{
    if( aInt==0 )
    {
        characters[ curPos++ ] = '0';
        return this;
    }
    ...
}
vladra
New User
 
Posts: 24
Joined: Fri Nov 16, 2007 6:18 pm
Location: Russia

Postby lawrie » Thu Nov 29, 2007 5:05 pm

Thanks for the fix - I have applied it to the development version and it will be in the next release. I hit a problem with StringBuffer recently and had it on a list of things to investigate before the next releaase. I think it was the same bug. We will need to investigate Math.log sometime. The problem was never reported on the RCX, so I don't know if the bug is specific to the NXT.
lawrie
leJOS Team Member
 
Posts: 934
Joined: Mon Feb 05, 2007 1:27 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff