PIPS
arith_fixprec.h File Reference

This header provides functions for performing fixed-precision arithmetic on integer or rational numbers. More...

#include <stdio.h>
#include <stdlib.h>
#include "assert.h"
#include "arithmetique.h"
+ Include dependency graph for arith_fixprec.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  qval_s
 

Macros

#define LINEAR_ARITH_FIXPREC_H
 
#define NOWUNUSED   __attribute__((unused))
 

Integers Functions

This section describes the functions for performing integer arithmetic.

These functions start with the prefix zval_. Integers are stored in objects of type zval_t.

#define zval_init(z)   ((z) = 0)
 Initialize z and set its value to 0. More...
 
#define zval_clear(z)
 Free the space occupied by z. More...
 
#define zval_set(z1, z2)   ((z1) = (z2))
 Set the value of z1 from z2. More...
 
#define zval_set_i(z, n)   ((z) = (n))
 Set the value of z from the signed long n. More...
 
#define zval_init_set(z1, z2)   ((z1) = (z2))
 Initialize z1 and set its value from z2. More...
 
#define zval_init_set_i(z, n)   ((z) = (n))
 Initialize z and set its value from the signed long n. More...
 
#define zval_get_i(z)   (z)
 Return the value of z as a signed long. More...
 
#define zval_add(z1, z2, z3)   ((z1) = (z2) + (z3))
 Set z1 to z2 + z3. More...
 
#define zval_sub(z1, z2, z3)   ((z1) = (z2) - (z3))
 Set z1 to z2 - z3. More...
 
#define zval_mul(z1, z2, z3)   ((z1) = value_protected_mult(z2, z3))
 Set z1 to z2 times z3. More...
 
#define zval_div(z1, z2, z3)   ((z1) = (z2) / (z3))
 Set z1 to z2/z3. More...
 
#define zval_addmul(z1, z2, z3)   ((z1) += value_protected_mult(z2, z3))
 Set z1 to z1 + z2 times z3. More...
 
#define zval_submul(z1, z2, z3)   ((z1) -= value_protected_mult(z2, z3))
 Set z1 to z1 - z2 times z3. More...
 
#define zval_neg(z1, z2)   ((z1) = -(z2))
 Set z1 to -z2. More...
 
#define zval_abs(z1, z2)   ((z1) = ABS(z2))
 Set z1 to the absolute value of z2. More...
 
#define zval_mod(z1, z2, z3)   ((z1) = (z2) % (z3))
 Set z1 to z2 mod z3. More...
 
#define zval_gcd(z1, z2, z3)   ((z1) = pgcd(z2, z3))
 Set z1 to the greatest common divisor of z2 and z3. More...
 
#define zval_lcm(z1, z2, z3)   ((z1) = ppcm(z2, z3))
 Set z1 to the least common multiple of z2 and z3. More...
 
#define zval_cmp(z1, z2)   ((z1) - (z2))
 Compare z1 and z2. More...
 
#define zval_cmp_i(z, n)   ((z) - (n))
 Compare z with a signed long n. More...
 
#define zval_sgn(z)   (value_sign(z))
 Return +1 if z > 0, 0 if z = 0, and -1 if z < 0. More...
 
#define zval_equal(z1, z2)   ((z1) == (z2))
 Return non-zero if z1 and z2 are equal, zero if they are non-equal. More...
 
#define zval_equal_i(z, n)   ((z) == (n))
 Return non-zero if z and the unsigned long n are equal, zero if they are non-equal. More...
 
#define zval_fprint(stream, z)   (fprintf(stream, "%li", z))
 Output z on stdio stream stream. More...
 
#define zval_print(z)   (printf("%li", z))
 Output z on stdout. More...
 
typedef long int zval_t
 Type of integer numbers. More...
 

Rational Number Functions

This section describes the functions for performing arithmetic on rational numbers.

These functions start with the prefix qval_. Rational numbers are stored in objects of type qval_t.

#define qval_clear(q)
 Free the space occupied by q. More...
 
#define qval_equal_i(q1, q2num, q2den)   (qval_cmp_i(q1, q2num, q2den) == 0)
 Return non-zero if q and q2num/q2den are equal, zero if they are non-equal. More...
 
#define qval_print(q)   (qval_fprint(stdout, q))
 Output q on stdout. More...
 
typedef struct qval_sqval_p
 
typedef qval_s qval_t[1]
 Type of rational numbers. More...
 
static void qval_canonicalize_unsafe (qval_t q)
 
static void NOWUNUSED qval_canonicalize (qval_t q)
 Remove any factors that are common to the numerator and denominator of q, and make the denominator positive. More...
 
static void NOWUNUSED qval_init (qval_t q)
 Initialize q and set its value to 0/1. More...
 
static void NOWUNUSED qval_set (qval_t q1, qval_t q2)
 Set the value of q1 from q2. More...
 
static void NOWUNUSED qval_set_i (qval_t q1, Value q2num, Value q2den)
 Set the value of q to q2num/q2den. More...
 
static void NOWUNUSED qval_add (qval_t q1, qval_t q2, qval_t q3)
 Set q1 to q2 + q3. More...
 
static void NOWUNUSED qval_sub (qval_t q1, qval_t q2, qval_t q3)
 Set q1 to q2 - q3. More...
 
static void NOWUNUSED qval_mul (qval_t q1, qval_t q2, qval_t q3)
 Set q1 to q2 times q3. More...
 
static void NOWUNUSED qval_div (qval_t q1, qval_t q2, qval_t q3)
 Set q1 to q2/q3. More...
 
static void NOWUNUSED qval_neg (qval_t q1, qval_t q2)
 Set q1 to -q2. More...
 
static void NOWUNUSED qval_abs (qval_t q1, qval_t q2)
 Set q1 to the absolute value of q2. More...
 
static void NOWUNUSED qval_inv (qval_t q1, qval_t q2)
 Set q1 to 1/q2. More...
 
static int NOWUNUSED qval_cmp (qval_t q1, qval_t q2)
 Compare q1 and q2. More...
 
static int NOWUNUSED qval_cmp_i (qval_t q1, Value q2num, Value q2den)
 Compare q1 and q2num/q2den. More...
 
static int NOWUNUSED qval_sgn (qval_t q)
 Return +1 if q > 0, 0 if q = 0, and -1 if q < 0. More...
 
static int NOWUNUSED qval_equal (qval_t q1, qval_t q2)
 Return non-zero if q1 and q2 are equal, zero if they are non-equal. More...
 
static int NOWUNUSED qval_fprint (FILE *stream, qval_t q)
 Output q on stdio stream stream. More...
 

Detailed Description

This header provides functions for performing fixed-precision arithmetic on integer or rational numbers.

Definition in file arith_fixprec.h.

Macro Definition Documentation

◆ LINEAR_ARITH_FIXPREC_H

#define LINEAR_ARITH_FIXPREC_H

Definition at line 40 of file arith_fixprec.h.

◆ NOWUNUSED

#define NOWUNUSED   __attribute__((unused))

Definition at line 48 of file arith_fixprec.h.

◆ qval_clear

#define qval_clear (   q)

Free the space occupied by q.

Definition at line 258 of file arith_fixprec.h.

◆ qval_equal_i

#define qval_equal_i (   q1,
  q2num,
  q2den 
)    (qval_cmp_i(q1, q2num, q2den) == 0)

Return non-zero if q and q2num/q2den are equal, zero if they are non-equal.

Definition at line 433 of file arith_fixprec.h.

◆ qval_print

#define qval_print (   q)    (qval_fprint(stdout, q))

Output q on stdout.

Definition at line 452 of file arith_fixprec.h.

◆ zval_abs

#define zval_abs (   z1,
  z2 
)    ((z1) = ABS(z2))

Set z1 to the absolute value of z2.

Definition at line 136 of file arith_fixprec.h.

◆ zval_add

#define zval_add (   z1,
  z2,
  z3 
)    ((z1) = (z2) + (z3))

Set z1 to z2 + z3.

Definition at line 101 of file arith_fixprec.h.

◆ zval_addmul

#define zval_addmul (   z1,
  z2,
  z3 
)    ((z1) += value_protected_mult(z2, z3))

Set z1 to z1 + z2 times z3.

Definition at line 121 of file arith_fixprec.h.

◆ zval_clear

#define zval_clear (   z)

Free the space occupied by z.

Definition at line 71 of file arith_fixprec.h.

◆ zval_cmp

#define zval_cmp (   z1,
  z2 
)    ((z1) - (z2))

Compare z1 and z2.

Return a positive value if z1 > z2, zero if z1 = z2, or a negative value if z1 < z2.

Definition at line 162 of file arith_fixprec.h.

◆ zval_cmp_i

#define zval_cmp_i (   z,
 
)    ((z) - (n))

Compare z with a signed long n.

Return a positive value if z > n, zero if z = n, or a negative value if z < n.

Definition at line 169 of file arith_fixprec.h.

◆ zval_div

#define zval_div (   z1,
  z2,
  z3 
)    ((z1) = (z2) / (z3))

Set z1 to z2/z3.

Definition at line 116 of file arith_fixprec.h.

◆ zval_equal

#define zval_equal (   z1,
  z2 
)    ((z1) == (z2))

Return non-zero if z1 and z2 are equal, zero if they are non-equal.

Definition at line 179 of file arith_fixprec.h.

◆ zval_equal_i

#define zval_equal_i (   z,
 
)    ((z) == (n))

Return non-zero if z and the unsigned long n are equal, zero if they are non-equal.

Definition at line 185 of file arith_fixprec.h.

◆ zval_fprint

#define zval_fprint (   stream,
 
)    (fprintf(stream, "%li", z))

Output z on stdio stream stream.

Definition at line 190 of file arith_fixprec.h.

◆ zval_gcd

#define zval_gcd (   z1,
  z2,
  z3 
)    ((z1) = pgcd(z2, z3))

Set z1 to the greatest common divisor of z2 and z3.

The result is always positive, irrespective of the signs of z2 and z3. Except if both inputs are zero; then it is undefined.

Definition at line 148 of file arith_fixprec.h.

◆ zval_get_i

#define zval_get_i (   z)    (z)

Return the value of z as a signed long.

Definition at line 96 of file arith_fixprec.h.

◆ zval_init

#define zval_init (   z)    ((z) = 0)

Initialize z and set its value to 0.

Definition at line 66 of file arith_fixprec.h.

◆ zval_init_set

#define zval_init_set (   z1,
  z2 
)    ((z1) = (z2))

Initialize z1 and set its value from z2.

Definition at line 86 of file arith_fixprec.h.

◆ zval_init_set_i

#define zval_init_set_i (   z,
 
)    ((z) = (n))

Initialize z and set its value from the signed long n.

Definition at line 91 of file arith_fixprec.h.

◆ zval_lcm

#define zval_lcm (   z1,
  z2,
  z3 
)    ((z1) = ppcm(z2, z3))

Set z1 to the least common multiple of z2 and z3.

The result is always positive, irrespective of the signs of z2 and z3. z1 will be zero if either z2 or z3 is zero.

Definition at line 155 of file arith_fixprec.h.

◆ zval_mod

#define zval_mod (   z1,
  z2,
  z3 
)    ((z1) = (z2) % (z3))

Set z1 to z2 mod z3.

Definition at line 141 of file arith_fixprec.h.

◆ zval_mul

#define zval_mul (   z1,
  z2,
  z3 
)    ((z1) = value_protected_mult(z2, z3))

Set z1 to z2 times z3.

Definition at line 111 of file arith_fixprec.h.

◆ zval_neg

#define zval_neg (   z1,
  z2 
)    ((z1) = -(z2))

Set z1 to -z2.

Definition at line 131 of file arith_fixprec.h.

◆ zval_print

#define zval_print (   z)    (printf("%li", z))

Output z on stdout.

Definition at line 195 of file arith_fixprec.h.

◆ zval_set

#define zval_set (   z1,
  z2 
)    ((z1) = (z2))

Set the value of z1 from z2.

Definition at line 76 of file arith_fixprec.h.

◆ zval_set_i

#define zval_set_i (   z,
 
)    ((z) = (n))

Set the value of z from the signed long n.

Definition at line 81 of file arith_fixprec.h.

◆ zval_sgn

#define zval_sgn (   z)    (value_sign(z))

Return +1 if z > 0, 0 if z = 0, and -1 if z < 0.

Definition at line 174 of file arith_fixprec.h.

◆ zval_sub

#define zval_sub (   z1,
  z2,
  z3 
)    ((z1) = (z2) - (z3))

Set z1 to z2 - z3.

Definition at line 106 of file arith_fixprec.h.

◆ zval_submul

#define zval_submul (   z1,
  z2,
  z3 
)    ((z1) -= value_protected_mult(z2, z3))

Set z1 to z1 - z2 times z3.

Definition at line 126 of file arith_fixprec.h.

Typedef Documentation

◆ qval_p

typedef struct qval_s * qval_p

◆ qval_t

typedef qval_s qval_t[1]

Type of rational numbers.

Definition at line 216 of file arith_fixprec.h.

◆ zval_t

typedef long int zval_t

Type of integer numbers.

Definition at line 61 of file arith_fixprec.h.

Function Documentation

◆ qval_abs()

static void NOWUNUSED qval_abs ( qval_t  q1,
qval_t  q2 
)
static

Set q1 to the absolute value of q2.

Definition at line 349 of file arith_fixprec.h.

350 {
351  zval_abs(q1->num, q2->num);
352  zval_set(q1->den, q2->den);
353 }
#define zval_abs(z1, z2)
Set z1 to the absolute value of z2.
#define zval_set(z1, z2)
Set the value of z1 from z2.
Definition: arith_fixprec.h:76

References zval_abs, and zval_set.

◆ qval_add()

static void NOWUNUSED qval_add ( qval_t  q1,
qval_t  q2,
qval_t  q3 
)
static

Set q1 to q2 + q3.

Definition at line 283 of file arith_fixprec.h.

284 {
285  zval_t q3num; zval_init(q3num); zval_set(q3num, q3->num);
286  zval_t lcm; zval_init(lcm); zval_lcm(lcm, q2->den, q3->den);
287  zval_t tmp; zval_init(tmp);
288  zval_div(tmp, lcm, q2->den);
289  zval_mul(q1->num, q2->num, tmp);
290  zval_div(tmp, lcm, q3->den);
291  zval_addmul(q1->num, q3num, tmp);
292  zval_set(q1->den, lcm);
293  zval_clear(q3num); zval_clear(lcm); zval_clear(tmp);
295 }
#define zval_mul(z1, z2, z3)
Set z1 to z2 times z3.
#define zval_clear(z)
Free the space occupied by z.
Definition: arith_fixprec.h:71
#define zval_div(z1, z2, z3)
Set z1 to z2/z3.
long int zval_t
Type of integer numbers.
Definition: arith_fixprec.h:61
#define zval_init(z)
Initialize z and set its value to 0.
Definition: arith_fixprec.h:66
#define zval_addmul(z1, z2, z3)
Set z1 to z1 + z2 times z3.
static void qval_canonicalize_unsafe(qval_t q)
#define zval_lcm(z1, z2, z3)
Set z1 to the least common multiple of z2 and z3.

References qval_canonicalize_unsafe(), zval_addmul, zval_clear, zval_div, zval_init, zval_lcm, zval_mul, and zval_set.

+ Here is the call graph for this function:

◆ qval_canonicalize()

static void NOWUNUSED qval_canonicalize ( qval_t  q)
static

Remove any factors that are common to the numerator and denominator of q, and make the denominator positive.

Definition at line 238 of file arith_fixprec.h.

239 {
240  if (zval_cmp_i(q->den, 0) < 0) {
241  zval_neg(q->num, q->num);
242  zval_neg(q->den, q->den);
243  }
245 }
#define zval_cmp_i(z, n)
Compare z with a signed long n.
#define zval_neg(z1, z2)
Set z1 to -z2.

References qval_canonicalize_unsafe(), zval_cmp_i, and zval_neg.

Referenced by qval_div(), qval_inv(), and qval_set_i().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qval_canonicalize_unsafe()

static void qval_canonicalize_unsafe ( qval_t  q)
static

Definition at line 218 of file arith_fixprec.h.

219 {
220  if (zval_cmp_i(q->num, 0) == 0) {
221  zval_set_i(q->den, 1);
222  return;
223  }
224  else {
225  zval_t gcd; zval_init(gcd);
226  zval_abs(gcd, q->num);
227  zval_gcd(gcd, gcd, q->den);
228  zval_div(q->num, q->num, gcd);
229  zval_div(q->den, q->den, gcd);
230  zval_clear(gcd);
231  }
232 }
#define zval_set_i(z, n)
Set the value of z from the signed long n.
Definition: arith_fixprec.h:81
#define zval_gcd(z1, z2, z3)
Set z1 to the greatest common divisor of z2 and z3.

References zval_abs, zval_clear, zval_cmp_i, zval_div, zval_gcd, zval_init, and zval_set_i.

Referenced by qval_add(), qval_canonicalize(), qval_mul(), and qval_sub().

+ Here is the caller graph for this function:

◆ qval_cmp()

static int NOWUNUSED qval_cmp ( qval_t  q1,
qval_t  q2 
)
static

Compare q1 and q2.

Return a positive value if q1 > q2, qero if q1 = q2, or a negative value if q1 < q2. To determine if two rationals are equal, qval_equal is faster than qval_cmp.

Definition at line 375 of file arith_fixprec.h.

376 {
377  zval_t lcm; zval_init(lcm); zval_lcm(lcm, q1->den, q2->den);
378  zval_t z1; zval_init(z1);
379  zval_t z2; zval_init(z2);
380  zval_t tmp; zval_init(tmp);
381  zval_div(tmp, lcm, q1->den);
382  zval_mul(z1, q1->num, tmp);
383  zval_div(tmp, lcm, q2->den);
384  zval_mul(z2, q2->num, tmp);
385  int res = zval_cmp(z1, z2);
386  zval_clear(lcm); zval_clear(z1); zval_clear(z2); zval_clear(tmp);
387  return res;
388 }
#define zval_cmp(z1, z2)
Compare z1 and z2.

References zval_clear, zval_cmp, zval_div, zval_init, zval_lcm, and zval_mul.

◆ qval_cmp_i()

static int NOWUNUSED qval_cmp_i ( qval_t  q1,
Value  q2num,
Value  q2den 
)
static

Compare q1 and q2num/q2den.

Return a positive value if q1 > q2num/q2den, zero if q1 = q2num/q2den, or a negative value if q1 < q2num/q2den.

Definition at line 396 of file arith_fixprec.h.

397 {
398  zval_t lcm; zval_init(lcm); zval_lcm(lcm, q1->den, q2den);
399  zval_t z1; zval_init(z1);
400  zval_t z2; zval_init(z2);
401  zval_t tmp; zval_init(tmp);
402  zval_div(tmp, lcm, q1->den);
403  zval_mul(z1, q1->num, tmp);
404  zval_div(tmp, lcm, q2den);
405  zval_mul(z2, q2num, tmp);
406  int res = zval_cmp(z1, z2);
407  zval_clear(lcm); zval_clear(z1); zval_clear(z2); zval_clear(tmp);
408  return res;
409 }

References zval_clear, zval_cmp, zval_div, zval_init, zval_lcm, and zval_mul.

◆ qval_div()

static void NOWUNUSED qval_div ( qval_t  q1,
qval_t  q2,
qval_t  q3 
)
static

Set q1 to q2/q3.

Definition at line 327 of file arith_fixprec.h.

328 {
329  zval_t q3num; zval_init(q3num); zval_set(q3num, q3->num);
330  assert(zval_cmp_i(q3num, 0) != 0);
331  zval_mul(q1->num, q2->num, q3->den);
332  zval_mul(q1->den, q2->den, q3num);
333  zval_clear(q3num);
334  qval_canonicalize(q1);
335 }
static void NOWUNUSED qval_canonicalize(qval_t q)
Remove any factors that are common to the numerator and denominator of q, and make the denominator po...
#define assert(ex)
Definition: newgen_assert.h:41

References assert, qval_canonicalize(), zval_clear, zval_cmp_i, zval_init, zval_mul, and zval_set.

+ Here is the call graph for this function:

◆ qval_equal()

static int NOWUNUSED qval_equal ( qval_t  q1,
qval_t  q2 
)
static

Return non-zero if q1 and q2 are equal, zero if they are non-equal.

Although qval_cmp can be used for the same purpose, this function is faster.

Definition at line 424 of file arith_fixprec.h.

425 {
426  return zval_cmp(q1->den, q2->den) == 0 && zval_cmp(q1->num, q2->num) == 0;
427 }

References zval_cmp.

◆ qval_fprint()

static int NOWUNUSED qval_fprint ( FILE *  stream,
qval_t  q 
)
static

Output q on stdio stream stream.

Definition at line 438 of file arith_fixprec.h.

439 {
440  int c;
441  c = zval_fprint(stream, q->num);
442  if (zval_cmp_i(q->den, 1)) {
443  c += fprintf(stream, "/");
444  c += zval_fprint(stream, q->den);
445  }
446  return c;
447 }
#define zval_fprint(stream, z)
Output z on stdio stream stream.
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References fprintf(), zval_cmp_i, and zval_fprint.

+ Here is the call graph for this function:

◆ qval_init()

static void NOWUNUSED qval_init ( qval_t  q)
static

Initialize q and set its value to 0/1.

Definition at line 250 of file arith_fixprec.h.

250  {
251  q->num = 0;
252  q->den = 1;
253 }

◆ qval_inv()

static void NOWUNUSED qval_inv ( qval_t  q1,
qval_t  q2 
)
static

Set q1 to 1/q2.

Definition at line 358 of file arith_fixprec.h.

359 {
360  zval_t q2num; zval_init(q2num); zval_set(q2num, q2->num);
361  assert(zval_cmp_i(q2num, 0) != 0);
362  zval_set(q1->num, q2->den);
363  zval_set(q1->den, q2num);
364  zval_clear(q2num);
365  qval_canonicalize(q1);
366 }

References assert, qval_canonicalize(), zval_clear, zval_cmp_i, zval_init, and zval_set.

+ Here is the call graph for this function:

◆ qval_mul()

static void NOWUNUSED qval_mul ( qval_t  q1,
qval_t  q2,
qval_t  q3 
)
static

Set q1 to q2 times q3.

Definition at line 317 of file arith_fixprec.h.

318 {
319  zval_mul(q1->num, q2->num, q3->num);
320  zval_mul(q1->den, q2->den, q3->den);
322 }

References qval_canonicalize_unsafe(), and zval_mul.

+ Here is the call graph for this function:

◆ qval_neg()

static void NOWUNUSED qval_neg ( qval_t  q1,
qval_t  q2 
)
static

Set q1 to -q2.

Definition at line 340 of file arith_fixprec.h.

341 {
342  zval_neg(q1->num, q2->num);
343  zval_set(q1->den, q2->den);
344 }

References zval_neg, and zval_set.

◆ qval_set()

static void NOWUNUSED qval_set ( qval_t  q1,
qval_t  q2 
)
static

Set the value of q1 from q2.

Definition at line 263 of file arith_fixprec.h.

264 {
265  zval_set(q1->num, q2->num);
266  zval_set(q1->den, q2->den);
267 }

References zval_set.

◆ qval_set_i()

static void NOWUNUSED qval_set_i ( qval_t  q1,
Value  q2num,
Value  q2den 
)
static

Set the value of q to q2num/q2den.

Definition at line 272 of file arith_fixprec.h.

273 {
274  assert(zval_cmp_i(q2den, 0) != 0);
275  zval_set_i(q1->num, q2num);
276  zval_set_i(q1->den, q2den);
277  qval_canonicalize(q1);
278 }

References assert, qval_canonicalize(), zval_cmp_i, and zval_set_i.

+ Here is the call graph for this function:

◆ qval_sgn()

static int NOWUNUSED qval_sgn ( qval_t  q)
static

Return +1 if q > 0, 0 if q = 0, and -1 if q < 0.

Definition at line 414 of file arith_fixprec.h.

415 {
416  return zval_sgn(q->num);
417 }
#define zval_sgn(z)
Return +1 if z > 0, 0 if z = 0, and -1 if z < 0.

References zval_sgn.

◆ qval_sub()

static void NOWUNUSED qval_sub ( qval_t  q1,
qval_t  q2,
qval_t  q3 
)
static

Set q1 to q2 - q3.

Definition at line 300 of file arith_fixprec.h.

301 {
302  zval_t q3num; zval_init(q3num); zval_set(q3num, q3->num);
303  zval_t lcm; zval_init(lcm); zval_lcm(lcm, q2->den, q3->den);
304  zval_t tmp; zval_init(tmp);
305  zval_div(tmp, lcm, q2->den);
306  zval_mul(q1->num, q2->num, tmp);
307  zval_div(tmp, lcm, q3->den);
308  zval_submul(q1->num, q3num, tmp);
309  zval_set(q1->den, lcm);
310  zval_clear(q3num); zval_clear(lcm); zval_clear(tmp);
312 }
#define zval_submul(z1, z2, z3)
Set z1 to z1 - z2 times z3.

References qval_canonicalize_unsafe(), zval_clear, zval_div, zval_init, zval_lcm, zval_mul, zval_set, and zval_submul.

+ Here is the call graph for this function: