Ignore:
Timestamp:
Jun 30, 2016, 4:32:56 PM (10 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
ea29e73
Parents:
1b5c81ed (diff), 84d4d6f (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 'master' into gc_noraii

Conflicts:

Jenkinsfile
src/SymTab/Validate.cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/rational.c

    r1b5c81ed rf80e0218  
    1111// Created On       : Wed Apr  6 17:54:28 2016
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Tue Apr 12 21:26:42 2016
    14 // Update Count     : 21
     13// Last Modified On : Wed May  4 14:16:14 2016
     14// Update Count     : 25
    1515//
    1616
     
    1818#include "fstream"
    1919#include "stdlib"
     20#include "math"                                                                                 // floor
    2021
    2122
     
    5253// constructors
    5354
    54 Rational rational() {
    55     return (Rational){ 0, 1 };
     55void ?{}( Rational * r ) {
     56    r{ 0, 1 };
    5657} // rational
    5758
    58 Rational rational( long int n ) {
    59     return (Rational){ n, 1 };
     59void ?{}( Rational * r, long int n ) {
     60    r{ n, 1 };
    6061} // rational
    6162
    62 Rational rational( long int n, long int d ) {
     63void ?{}( Rational * r, long int n, long int d ) {
    6364    long int t = simplify( &n, &d );                                    // simplify
    64     return (Rational){ n / t, d / t };
     65    r->numerator = n / t;
     66        r->denominator = d / t;
    6567} // rational
    6668
     
    171173Rational narrow( double f, long int md ) {
    172174        if ( md <= 1 ) {                                                                        // maximum fractional digits too small?
    173                 Rational t = rational( f, 1 );                                  // truncate fraction
    174                 return t;
     175                return (Rational){ f, 1};                                               // truncate fraction
    175176        } // if
    176177
     
    198199                k[2] = x * k[1] + k[0]; k[0] = k[1]; k[1] = k[2];
    199200        } // for
    200         Rational t = rational( neg ? -h[1] : h[1], k[1] );
    201         return t;
     201        return (Rational){ neg ? -h[1] : h[1], k[1] };
    202202} // narrow
    203203
Note: See TracChangeset for help on using the changeset viewer.