abc/src/bdd/cudd/cuddApa.c
/**Function********************************************************************

  Synopsis    [Compares the ratios of two arbitrary precision integers to two
  unsigned ints.]

  Description [Compares the ratios of two arbitrary precision integers
  to two unsigned ints. Returns 1 if the first number is larger; 0 if
  they are equal; -1 if the second number is larger.]

  SideEffects [None]

  SeeAlso     []

******************************************************************************/
Function
Synopsis    [Compares the ratios of two arbitrary precision integers to two
unsigned ints.]

Description [Compares the ratios of two arbitrary precision integers
to two unsigned ints. Returns 1 if the first number is larger; 0 if
they are equal; -1 if the second number is larger.]




Function Synopsis [ Compares the ratios of two arbitrary precision integers to two unsigned ints . ] Description [ Compares the ratios of two arbitrary precision integers to two unsigned ints . Returns 1 if the first number is larger ; 0 if they are equal ; - 1 if the second number is larger . ]
int
Cudd_ApaCompareRatios(
  int digitsFirst,
  DdApaNumber firstNum,
  unsigned int firstDen,
  int digitsSecond,
  DdApaNumber secondNum,
  unsigned int secondDen)
{
    int result;
    DdApaNumber first, second;
    unsigned int firstRem, secondRem;
    first = Cudd_NewApaNumber(digitsFirst);
    firstRem = Cudd_ApaIntDivision(digitsFirst,firstNum,firstDen,first);
    second = Cudd_NewApaNumber(digitsSecond);
    secondRem = Cudd_ApaIntDivision(digitsSecond,secondNum,secondDen,second);
    result = Cudd_ApaCompare(digitsFirst,first,digitsSecond,second);
    ABC_FREE(first);
    ABC_FREE(second);
    if (result == 0) {
        if ((double)firstRem/firstDen > (double)secondRem/secondDen)
            return(1);
        else if ((double)firstRem/firstDen < (double)secondRem/secondDen)
            return(-1);
    }
    return(result);
}
int Cudd_ApaCompareRatios ( int digitsFirst , DdApaNumber firstNum , unsigned int firstDen , int digitsSecond , DdApaNumber secondNum , unsigned int secondDen ) { int result ; DdApaNumber first , second ; unsigned int firstRem , secondRem ; first = Cudd_NewApaNumber ( digitsFirst ) ; firstRem = Cudd_ApaIntDivision ( digitsFirst , firstNum , firstDen , first ) ; second = Cudd_NewApaNumber ( digitsSecond ) ; secondRem = Cudd_ApaIntDivision ( digitsSecond , secondNum , secondDen , second ) ; result = Cudd_ApaCompare ( digitsFirst , first , digitsSecond , second ) ; ABC_FREE ( first ) ; ABC_FREE ( second ) ; if ( result == 0 ) { if ( ( double ) firstRem / firstDen > ( double ) secondRem / secondDen ) return ( 1 ) ; else if ( ( double ) firstRem / firstDen < ( double ) secondRem / secondDen ) return ( -1 ) ; } return ( result ) ; }
Function
Synopsis    [Compares the ratios of two arbitrary precision integers to two
unsigned ints.]
Function Synopsis [ Compares the ratios of two arbitrary precision integers to two unsigned ints . ]