Back to index

php5  5.3.10
Functions
divmod.c File Reference
#include <config.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include "bcmath.h"
#include "private.h"

Go to the source code of this file.

Functions

int bc_divmod (bc_num num1, bc_num num2, bc_num *quot, bc_num *rem, int scale TSRMLS_DC)
int bc_modulo (bc_num num1, bc_num num2, bc_num *result, int scale TSRMLS_DC)

Function Documentation

int bc_divmod ( bc_num  num1,
bc_num  num2,
bc_num quot,
bc_num rem,
int scale  TSRMLS_DC 
)

Definition at line 48 of file divmod.c.

{
  bc_num quotient = NULL;
  bc_num temp;
  int rscale;

  /* Check for correct numbers. */
  if (bc_is_zero (num2 TSRMLS_CC)) return -1;

  /* Calculate final scale. */
  rscale = MAX (num1->n_scale, num2->n_scale+scale);
  bc_init_num(&temp TSRMLS_CC);

  /* Calculate it. */
  bc_divide (num1, num2, &temp, scale TSRMLS_CC);
  if (quot)
    quotient = bc_copy_num (temp);
  bc_multiply (temp, num2, &temp, rscale TSRMLS_CC);
  bc_sub (num1, temp, rem, rscale);
  bc_free_num (&temp);

  if (quot)
    {
      bc_free_num (quot);
      *quot = quotient;
    }

  return 0;   /* Everything is OK. */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int bc_modulo ( bc_num  num1,
bc_num  num2,
bc_num result,
int scale  TSRMLS_DC 
)

Definition at line 83 of file divmod.c.

{
  return bc_divmod (num1, num2, NULL, result, scale TSRMLS_CC);
}

Here is the call graph for this function:

Here is the caller graph for this function: