Jump to content

Recommended Posts

This is more of a mathmatical question but if anyone knows, I'd really appreciate it.

 

Say I have two numbers, for example 150 and 450....and a third number between them, say 250. I want to calculate the percentage of 250 between 150 and 450, where 150 is the 0%, and 450 is the 100%. I know there is a certain formula, but seeing math was never my favorite course, I can't just figure it out.  :)

Link to comment
https://forums.phpfreaks.com/topic/65783-solved-percentages/
Share on other sites

Huge sigh:

 

$whole_thing = $high_num - $low_num; // the range, or 100%, e.g. 450-150=300
$part_thing = $some_number - $low_num; // the unknown bit of the range, e.g. 250-150=100
$percent = 100 * $part_thing / $whole_thing;// .g. 100*100/300 = 33.33%

 

Worked like a charm. Thanks!  :)

Link to comment
https://forums.phpfreaks.com/topic/65783-solved-percentages/#findComment-328676
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.