Ignore:
Timestamp:
May 4, 2016, 2:52:18 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
9e2c1f0
Parents:
2bdf50d (diff), d1ab5331 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ctor' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc into ctor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/rational.c

    r2bdf50d r99ee64d  
    1111// Created On       : Wed Apr  6 17:54:28 2016
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Thu Apr 21 07:33:03 2016
    14 // Update Count     : 22
     13// Last Modified On : Wed May  4 14:16:14 2016
     14// Update Count     : 25
    1515//
    1616
     
    5353// constructors
    5454
    55 Rational rational() {
    56     return (Rational){ 0, 1 };
     55void ?{}( Rational * r ) {
     56    r{ 0, 1 };
    5757} // rational
    5858
    59 Rational rational( long int n ) {
    60     return (Rational){ n, 1 };
     59void ?{}( Rational * r, long int n ) {
     60    r{ n, 1 };
    6161} // rational
    6262
    63 Rational rational( long int n, long int d ) {
     63void ?{}( Rational * r, long int n, long int d ) {
    6464    long int t = simplify( &n, &d );                                    // simplify
    65     return (Rational){ n / t, d / t };
     65    r->numerator = n / t;
     66        r->denominator = d / t;
    6667} // rational
    6768
     
    172173Rational narrow( double f, long int md ) {
    173174        if ( md <= 1 ) {                                                                        // maximum fractional digits too small?
    174                 Rational t = rational( f, 1 );                                  // truncate fraction
    175                 return t;
     175                return (Rational){ f, 1};                                               // truncate fraction
    176176        } // if
    177177
     
    199199                k[2] = x * k[1] + k[0]; k[0] = k[1]; k[1] = k[2];
    200200        } // for
    201         Rational t = rational( neg ? -h[1] : h[1], k[1] );
    202         return t;
     201        return (Rational){ neg ? -h[1] : h[1], k[1] };
    203202} // narrow
    204203
Note: See TracChangeset for help on using the changeset viewer.