我如何在PHP中将分子除以任何类似的0.0110932?

I'm getting error like PHP

Warning: Division by zero error.

I'm still and want to calculate some problems. If you can tell me, how can calculate antilog / log inverse with examples, I'll be more satisfied.

<?
    if(isset($_POST['submit'])) 
    { 
       $P=$_POST['P'];  // P=100000
       $rate=$_POST['rate']; // rate = 10.5
       $R=($rate/100);
       $N=$_POST['N']; // N = 78
       echo $P ."<br>" ;
       echo $R ."<br>" ;
       echo $N ."<br>" ;
       $NEW=($R/12);   // NEW = .00875
       $aa = (1+($NEW)); // aa = 1.00875
       $ab = bcpow('$aa', '$N',16); // ab = 1.9729529246182467
       $ac = ($ab-1); // ac = 0.9729529246182467
       $ad = bcdiv('$ab', '$ac', 3); // Div by Zero Error 
       $M = ($P*$NEW) *($ad);
       echo "The Installment is : " . $M . "<br>";
    }
?>

To narrow down where your issue is coming from: string bcdiv ( string $left_operand , string $right_operand [, int $scale ] )

bcdiv will return Division by zero only if the right operand is 0, so you can backtrace this by assuming $ac is your culprint. Try echoing $ac before the bcdiv function call to ensure it is not empty.

I'm willing to bet that this line $ac = ($ab-1); // ac = 0.9729529246182467 $ac is going negative.

You should also remove your single quotes, don't take the manual so literal. You can still pass in an int or double and the function will convert it for you. even if you cast the variable as a double.

//WITHOUT QUOTES
$ab = '1.9729529246182467';
$ac = ($ab-1);
echo bcdiv($ab, $ac, 3);
//output (2.027)

//WITH QUOTES
$ab = '1.9729529246182467';
$ac = ($ab-1);
echo bcdiv($ab, '$ac', 3);
//output Warning (2): bcdiv() [function.bcdiv]: Division by zero

bcpow('$aa', '$N',16); are you sure these variables get parsed? They are treated as a string in single quotes, and since there is no number they might be just bogus. (typing $aa^$n on a calculator will fail).

You can use bcpow("'".$aa."'", "'".$N."'",16); or try using double quotes.

I didn't understood your code as well, but here is the code that calculate Antilog / log of a value

<?php

$log = 11;
$e   = 2.718281828;
$dn  = 1;

// Calculate Antilog of $log = 11
$ans = pow($e, $log);
$antilog = round($ans*10000)/10000;
echo "<br /> Antilog : ".$antilog;

// Calculate Log of $log = 11
$ans = log($log)/$dn;
$log = round($ans*10000)/10000;
echo "<br /> Log : ".$log;

// Calculate Antilog / Log of $log = 11
echo "<br /> Antilog / Log : ".($antilog / $log);
?>

Result:

Antilog : 59874.1416
Log : 2.3979
Antilog / Log : 24969.407231327
Hope this help you, if else please provide more details (comments) on your code.

The line with the problem:

$ad = bcdiv('$ab', '$ac', 3); // Div by Zero Error

The problem here is because $ab and $ac are in quotes. They shouldn't be.

Having them in quotes means that PHP sees $ab as being a string consisting of the characters $, a and b, instead of the numeric value of the $ab variable.

Remove the quotes, and it should start working.

The same applies to the bcpow() line.