Re: Promoting unsigned long int to long int



pereges <Broli00@xxxxxxxxx> wrote:
On Jun 30, 5:07 pm, j...@xxxxxxxxxxx (Jens Thoms Toerring) wrote:

Using unsigned long should be completely ok.

Ok.

And j gets set to ULONG_MAX (unsigned integers "wrap around").
That will keep you in this loop for a loooong time and you will
try to access elements of your array that don't exist, rather
likely resulting in a crash.

Yeah, I notice that too.

The simplest solution is to just bail out of the function if
left is equal to right - there's nothing to sort in that case.

You mean :

void quicksort (void quicksort(vector **parent_vpa, ulong left, ulong
right, uchar
axis)
{
ulong i, j;

if (left == right)

Not exactly;-) I they're the same there's nothing to sort since
your array only has a single element, so I meant

if ( left < right )
{
i = left;
j = right;

while (i <= j)
{
...
}
if (left < j)
{
quicksort(parent_vpa, left, j, axis);
}

if (i < right)
{
quicksort(parent_vpa, i, right, axis);
}

}
else
return;
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.



Relevant Pages

  • Re: Promoting unsigned long int to long int
    ... I'm using the quick sort method. ... The array of pointers ... The axis can take ... Since i and j are equal you get into this loop. ...
    (comp.lang.c)
  • Re: ExceptionInInitializerError in Castor
    ... I tried printing the byte array and it prints the exact xml file that is being sent by the application calling this webservice. ... I am running axis on Tomcat 4.1.29 But when I try to unmarshall the byte array, ... Since it seems exceedingly unlikely that one of the Commons Logging's own loggers would fail to implement its Log interface, the most likely scenario is multiple versions of the Commons Logging package in the classpath. ... This sort of thing sometimes happens when an application or package, such as Axis, Castor, or Tomcat comes packaged with various external libraries, such as Commons Logging. ...
    (comp.lang.java.programmer)
  • Kalman Filter
    ... I am creating a algorithm suite for a new virtual IMU design. ... based on an array of gyros and accelerometers for each axis. ...
    (comp.soft-sys.matlab)
  • Re: Crypting the webservice responses in AXIS
    ... original array without problems because on the client side the BASE64 ... Before the BASE64 String is sended back, I am interested to encrypt it ... it is possible in some way to ask AXIS to crypt/decrypt ...
    (comp.lang.java.programmer)
  • Re: Week numbers on X-axis
    ... Was that your question about the number of X axis ticks? ... Store your array in a ... > I have a chart that should display the project status over ... > I save the wanted x-axis in an array and ...
    (microsoft.public.excel.charting)