Mathematical Equation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Mathematical Equation

Post by HaVoC »

How would I do this? I kept getting parse errors. I tried this.

Code: Select all

<?php
($wins / $losses) * 100
?>
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

What is it that you want to do? Print out the solution?

If so, assuming that both $wins and $losses have been declared, and $losses is not zero than you can print the solution by doing:

Code: Select all

echo $wins / $losses * 100;
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

You could try:

Code: Select all

<?php
if ($losses>'0'){
$result = $wins / $losses * 100;
}
else{
$result = "Can not be calculated!";
}

echo $result;

?>
If you are trying to get the percentage of losses, you have to take the total amount of games:

Code: Select all

<?php
if (($losses+$wins)>'0'){
$result = $wins / ($wins+$losses) * 100;
}
else{
$result = "Can not be calculated!";
}

echo $result;

?>
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Hey havoc, you make that signature up? Definitely something that people could spend many hours thinking about :)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

It's the same thing as "The above statement is true" and a few others

a real mind boggler tho :P
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Post by HaVoC »

The signature is a riddle. I haven't found the real answer for it. But I made up my own. It drove me insane. So the answer to the riddle in my opinion is insanity. Btw, Thanks a bunch Dr.Evil
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

haha.. your sig reminds me of politicians..

which one to believe.. hmm..
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

Post by toms100 »

hehe, the ultimate paradox, "this statement is false"
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

It's not the wording of the statement but the message it conveys, whether it's "the statement below is true" or "the line below is true" is of no importance.

A real mind boggler :)
Post Reply