6 Replies - 343 Views - Last Post: 08 October 2009 - 09:47 PM Rate Topic: -----

#1 messianic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 83
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#3 messianic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

#4 messianic  Icon User is offline

  • New D.I.C Head

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

Re: help with math function

Posted 08 October 2009 - 06:35 PM

ANYONE PLEASE
Was This Post Helpful? 0
  • +
  • -

#5 syfran  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 83
  • View blog
  • 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.
Was This Post Helpful? 1
  • +
  • -

#6 pbl  Icon User is offline

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

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: help with math function

Posted 08 October 2009 - 09:28 PM

View Postsyfran, 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

Was This Post Helpful? 0
  • +
  • -

#7 AntonWebsters  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 88
  • View blog
  • Posts: 428
  • Joined: 15-August 09

Re: help with math function

Posted 08 October 2009 - 09:47 PM

View Postmessianic, 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

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1