FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Bugs
   Bug Fixes, Implemented Suggestions
(Moderator: fry)
   max?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: max?  (Read 540 times)
kevinP

Email
max?
« on: Feb 15th, 2004, 1:16am »

Code:

int x1 = 30;
int x2 = 100;
int x3 = 170;
 
println( max(x1, x2, x3) );

 
Am I misunderstanding this? I expected max() to return 170, but I get 100 in this example.
 
-K
« Last Edit: Feb 15th, 2004, 1:17am by kevinP »  

Kevin Pfeiffer
benelek

35160983516098 WWW Email
Re: max?
« Reply #1 on: Feb 15th, 2004, 12:56pm »

it seems to be related to the order of arguments used. the third argument (in this case x3) seems to be ignored, so only the first two arguments are considered. note that if you use max(x1,x3,x2) you get the right result.
 
kevinP

Email
Re: max?
« Reply #2 on: Feb 15th, 2004, 1:32pm »

Hi,
 
The docs say: "Determines the largest value in a sequence of numbers.
     
Syntax      
max(value1, value2)
max(value1, value2, value 3)"
 
Which is why I though it must be a bug. For now I'll just use my own max() routine.
 
-K
 
 

Kevin Pfeiffer
toxi_
Guest
Email
Re: max?
« Reply #3 on: Feb 15th, 2004, 1:47pm »

thanks kevin for finding that one! i confirmed and fixed it for the next rev.
 
kevinP

Email
Re: max?
« Reply #4 on: Feb 15th, 2004, 1:50pm »

But who knows what beautiful Processing projects you've meanwhile broken which depended on this unique version?  
 

Kevin Pfeiffer
toxi

WWW
Re: max?
« Reply #5 on: Feb 15th, 2004, 2:09pm »

well, that's the joy of using alpha versions! c'est la vie...
 
here's the fixed code, trouble was that b never got compared with c...
 
Code:
int _max(int a, int b, int c) {
  return (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c);
}

 
also, it's only the integer version which is broken at current.
 
hth!
 

http://toxi.co.uk/
fry


WWW
Re: max?
« Reply #6 on: Feb 18th, 2004, 3:21pm »

ah, it's also the joy of peer review in an open project to have dumb mistakes aired for an audience of hundreds/thousands
 
fixed for the next release, min() had the same problem.
« Last Edit: Feb 18th, 2004, 3:23pm by fry »  
fry


WWW
Re: max?
« Reply #7 on: Mar 28th, 2004, 8:46pm »

fixed in bug release rev 69.
 
Pages: 1 

« Previous topic | Next topic »