# help with math function

Page 1 of 1

## 6 Replies - 662 Views - Last Post: 08 October 2009 - 09:47 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=130821&amp;s=ab50ebd2f07f4847eee34abdccf6337a&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 messianic

Reputation: 0
• Posts: 37
• Joined: 03-September 09

# help with math function

Posted 08 October 2009 - 06:14 PM

Can someone explain what the following code does?

```Math.max(Math.max(right,pt.x) - myTopLeft.x, mySize.width);

```

I know the Math.max in the parenthesis takes the larger value (either right or pt.x) but I'm confused after that.

Are we taking the larger value between myTopLeft.x and mySize.width and then minusing the larger value from either right or pt.x?
Is This A Good Question/Topic? 0

## Replies To: help with math function

### #2 syfran

• D.I.C Lover

Reputation: 83
• Posts: 1,103
• Joined: 12-July 09

## Re: help with math function

Posted 08 October 2009 - 06:18 PM

what are the variables right,pt,myTopLeft and mySize?

My guess is it gets the longest size of a rectangle.

### #3 messianic

Reputation: 0
• Posts: 37
• Joined: 03-September 09

## Re: help with math function

Posted 08 October 2009 - 06:27 PM

does it actually matter what the variables are? i'm trying to understand what the code actually means

### #4 messianic

Reputation: 0
• Posts: 37
• Joined: 03-September 09

## Re: help with math function

Posted 08 October 2009 - 06:35 PM

### #5 syfran

• D.I.C Lover

Reputation: 83
• Posts: 1,103
• Joined: 12-July 09

## Re: help with math function

Posted 08 October 2009 - 08:19 PM

Saying help me in all caps isn't going to help you. If you really want to know what it means you need context. Right now all I can tell you is exactly what is on the line.

### #6 pbl

• There is nothing you can't do with a JTable

Reputation: 8378
• Posts: 31,956
• Joined: 06-March 08

## Re: help with math function

Posted 08 October 2009 - 09:28 PM

syfran, on 8 Oct, 2009 - 07:19 PM, said:

Saying help me in all caps isn't going to help you. If you really want to know what it means you need context. Right now all I can tell you is exactly what is on the line.

Syfran is right

Math.max(Math.max(right,pt.x) - myTopLeft.x, mySize.width);

just decompose it

int p1 = max(right, pt.x);
.... oups... max can return int, long, float, double... I can't continue unless you provide us with more info

Quote

does it actually matter what the variables are? i'm trying to understand what the code actually means

Yes it DOES matter
If you know coding enough to determine what matters and what does not matter you DO NOT need our help to fix this beginner's problem

Your attitude really p* me off

This post has been edited by pbl: 08 October 2009 - 09:53 PM

### #7 AntonWebsters

• D.I.C Regular

Reputation: 89
• Posts: 428
• Joined: 15-August 09

## Re: help with math function

Posted 08 October 2009 - 09:47 PM

messianic, on 8 Oct, 2009 - 05:14 PM, said:

Can someone explain what the following code does?

```Math.max(Math.max(right,pt.x) - myTopLeft.x, mySize.width);

```

I know the Math.max in the parenthesis takes the larger value (either right or pt.x) but I'm confused after that.

Are we taking the larger value between myTopLeft.x and mySize.width and then minusing the larger value from either right or pt.x?

Isn't this very obvious? First of all, the code gets the max value from "right" and "pt.x". Alright, let's say the max value is "right". And then, the code finds the max value between "right" - myTopLeft.x, and mySize.width.

Quote

Your attitude really p* me off

This post has been edited by AntonWebsters: 08 October 2009 - 09:50 PM