Changeset ee06e41b for tests/sum.cfa
- Timestamp:
- Feb 18, 2019, 1:04:30 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- d08beee
- Parents:
- ada4575
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/sum.cfa
rada4575 ree06e41b 11 11 // Created On : Wed May 27 17:56:53 2015 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : S at Feb 9 15:38:48201914 // Update Count : 29313 // Last Modified On : Sun Feb 17 22:54:16 2019 14 // Update Count : 328 15 15 // 16 16 … … 34 34 } // sum 35 35 36 // Not in prelude.37 unsigned char ?+?( unsigned char t1, unsigned char t2 ) { return (int)t1 + t2; } // cast forces integer addition, otherwise recursion38 unsigned char ?+=?( unsigned char & t1, unsigned char t2 ) { t1 = t1 + t2; return t1; }39 unsigned char ++?( unsigned char & t ) { t += 1; return t; }40 unsigned char ?++( unsigned char & t ) { unsigned char temp = t; t += 1; return temp; }41 42 // Not in prelude.43 void ?{}( unsigned char & c, zero_t ) { c = 0; }44 void ?{}( int & i, zero_t ) { i = 0; }45 void ?{}( float & f, zero_t ) { f = 0.0; }46 void ?{}( double & d, zero_t ) { d = 0.0; }47 48 36 int main( void ) { 49 37 const int low = 5, High = 15, size = High - low; 50 38 51 unsigned char s = 0, a[size], v = (char)low;52 for ( int i = 0; i < size; i += 1, v += 1 ) {39 signed char s = 0, a[size], v = (char)low; 40 for ( int i = 0; i < size; i += 1, v += 1hh ) { 53 41 s += v; 54 42 a[i] = v; 55 43 } // for 56 44 sout | "sum from" | low | "to" | High | "is" 57 | sum( size, (unsigned char *)a ) | ", check" | (int)s; 45 | sum( size, (signed char *)a ) | ", check" | (int)s; 46 47 unsigned char s = 0, a[size], v = low; 48 for ( int i = 0; i < size; i += 1, v += 1hhu ) { 49 s += (unsigned char)v; 50 a[i] = (unsigned char)v; 51 } // for 52 sout | "sum from" | low | "to" | High | "is" 53 | sum( size, (unsigned char *)a ) | ", check" | (unsigned char)s; 54 55 short int s = 0, a[size], v = low; 56 for ( int i = 0; i < size; i += 1, v += 1h ) { 57 s += (short int)v; 58 a[i] = (short int)v; 59 } // for 60 sout | "sum from" | low | "to" | High | "is" 61 | sum( size, (short int *)a ) | ", check" | (short int)s; 58 62 59 63 int s = 0, a[size], v = low;
Note: See TracChangeset
for help on using the changeset viewer.