Changeset fe97a7d8 for src/prelude
- Timestamp:
- Jul 22, 2017, 11:05:35 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 637ff81, 72457b6
- Parents:
- 6b0b624
- git-author:
- Peter A. Buhr <pabuhr@…> (07/22/17 10:59:19)
- git-committer:
- Peter A. Buhr <pabuhr@…> (07/22/17 11:05:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/prelude/builtins.c
r6b0b624 rfe97a7d8 10 10 // Created On : Fri Jul 21 16:21:03 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 21 17:01:54201713 // Update Count : 1 112 // Last Modified On : Sat Jul 22 10:34:20 2017 13 // Update Count : 13 14 14 // 15 15 … … 38 38 static inline long double _Complex ?\?( long double _Complex x, _Complex long double y ) { return cpowl( x, y ); } 39 39 40 static inline long int ?\?( long int pe, unsigned longy ) { // disallow negative exponent40 static inline long int ?\?( long int ep, unsigned long int y ) { // disallow negative exponent 41 41 if ( y == 0 ) return 1; // base case 42 if ( pe == 2 ) return pe<< (y - 1); // special case, positive shifting only43 typeof( pe ) po= 1; // accumulate odd product42 if ( ep == 2 ) return ep << (y - 1); // special case, positive shifting only 43 typeof( ep ) op = 1; // accumulate odd product 44 44 for ( ; y > 1; y >>= 1 ) { // squaring exponentiation, O(log2 y) 45 if ( (y & 1) == 1 ) po *= pe; // odd ?46 pe *= pe;47 } // while48 return pe * po;45 if ( (y & 1) == 1 ) op *= ep; // odd ? 46 ep *= ep; 47 } // for 48 return ep * op; 49 49 } // ?\? 50 50 51 // FIX ME, cannot resolve the "T po= 1".51 // FIX ME, cannot resolve the "T op = 1". 52 52 53 53 // static inline forall( otype T | { void ?{}( T * this, one_t ); T ?*?( T, T ); } ) 54 // T ?\?( T pe, unsigned longy ) {54 // T ?\?( T ep, unsigned long int y ) { 55 55 // if ( y == 0 ) return 1; 56 // T po= 1;56 // T op = 1; 57 57 // for ( ; y > 1; y >>= 1 ) { // squaring exponentiation, O(log2 y) 58 // if ( (y & 1) == 1 ) po = po * pe; // odd ?59 // pe = pe * pe;58 // if ( (y & 1) == 1 ) op = op * ep; // odd ? 59 // ep = ep * ep; 60 60 // } // for 61 // return pe * po;61 // return ep * op; 62 62 // } // ?\? 63 63 64 64 // unsigned computation may be faster and larger 65 static inline unsigned long int ?\?( unsigned long int pe, unsigned longy ) { // disallow negative exponent65 static inline unsigned long int ?\?( unsigned long int ep, unsigned long int y ) { // disallow negative exponent 66 66 if ( y == 0 ) return 1; // base case 67 if ( pe == 2 ) return pe<< (y - 1); // special case, positive shifting only68 typeof( pe ) po= 1; // accumulate odd product67 if ( ep == 2 ) return ep << (y - 1); // special case, positive shifting only 68 typeof( ep ) op = 1; // accumulate odd product 69 69 for ( ; y > 1; y >>= 1 ) { // squaring exponentiation, O(log2 y) 70 if ( (y & 1) == 1 ) po *= pe; // odd ?71 pe *= pe;72 } // while73 return pe * po;70 if ( (y & 1) == 1 ) op *= ep; // odd ? 71 ep *= ep; 72 } // for 73 return ep * op; 74 74 } // ?\? 75 75 76 static inline double ?\?( long int x, signed long y ) { // allow negative exponent76 static inline double ?\?( long int x, signed long int y ) { // allow negative exponent 77 77 if ( y >= 0 ) return (double)(x \ (unsigned long int)y); 78 78 else return 1.0 / x \ (unsigned int)(-y); … … 80 80 81 81 static inline forall( otype T | { void ?{}( T * this, one_t ); T ?*?( T, T ); double ?/?( double, T ); } ) 82 double ?\?( T x, signed long y ) {82 double ?\?( T x, signed long int y ) { 83 83 if ( y >= 0 ) return (double)(x \ (unsigned long int)y); 84 else return 1.0 / x \ (unsigned int)(-y);84 else return 1.0 / x \ (unsigned long int)(-y); 85 85 } // ?\? 86 86 87 static inline long int ?\=?( long int * x, unsigned long y ) { *x = *x \ y; return *x; }88 static inline long int ?\=?( unsigned long int * x, unsigned longy ) { *x = *x \ y; return *x; }89 static inline int ?\=?( int * x, unsigned long y ) { *x = *x \ y; return *x; }90 static inline int ?\=?( unsigned int * x, unsigned longy ) { *x = *x \ y; return *x; }87 static inline long int ?\=?( long int * x, unsigned long int y ) { *x = *x \ y; return *x; } 88 static inline unsigned long int ?\=?( unsigned long int * x, unsigned long int y ) { *x = *x \ y; return *x; } 89 static inline int ?\=?( int * x, unsigned long int y ) { *x = *x \ y; return *x; } 90 static inline unsigned int ?\=?( unsigned int * x, unsigned long int y ) { *x = *x \ y; return *x; } 91 91 92 92 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.