php百分比计算

时间:2012-08-12 18:44:05

标签: php math

我正在尝试计算在线扑克中激活奖金所需的手数。

举个例子:

使用betfair扑克

  • 每个罐子的5%用于耙子
  • 3.25玩家积分将以佣金中提供的每一美元奖励

所以

平均底池$ 1的100手扑克手牌获得5美元的佣金 5 x 3.25 = 16.25分

奖金以每个40美元的5美元的增量发布,因此我需要计算生成40个点所需的手数。

以下是我目前的代码:

$average_pot = 1;
$points_required = 40;

//percentage of rake taken from pot
$rake_percentage = 5;
//number of points for every dollar generated
$points_per_dollar = 3.25;
$rake_to_generate = $points_required / $points_per_dollar; // 12.30
$hands_needed = $rake_to_generate * $rake_percentage; //Wrong?!?!

 echo $hands_needed;

我知道它可能很容易,但由于某种原因,我的大脑不会让我弄清楚,所以任何帮助都会非常感激。

2 个答案:

答案 0 :(得分:1)

$points_per_hand = $rake_percentage/100 * $points_per_dollar * $average_pot;
$hands_needed    = ceil($points_required / $points_per_hand);

使用您的示例:

$points_per_hand = 5/100 * 3.25 * 1;
                 = 0.1625;

$hands_needed    = ceil(40 / 0.1625);
                 = ceil(246.1538...);
                 = 247;

答案 1 :(得分:0)

试试这个:

$average_pot = 1;
$points_required = 40;

//percentage of rake taken from pot
$rake_percentage = 0.05;
//number of points for every dollar generated
$points_per_dollar = 3.25;
$rake_to_generate = $points_required / $points_per_dollar; // 12.30
$hands_needed = $rake_to_generate * $rake_percentage; //Wrong?!?!

echo $ hands_needed;