Ignore:
Timestamp:
Oct 30, 2024, 11:05:29 PM (11 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
292d6cf6
Parents:
a3bd827
Message:

proofread background chapter, and other small changes

Location:
doc/theses/mike_brooks_MMath/programs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/mike_brooks_MMath/programs/bkgd-carray-arrty.c

    ra3bd827 r520fa9e  
    5151        void f( float (*pa)[10] ) {
    5252                static_assert( sizeof( *pa ) == 40 ); $\C{// array}$
    53                 static_assert( sizeof( pa ) == 8 );     $\C{// pointer to array}$
     53                static_assert( sizeof( pa ) == 8 ); $\C{// pointer to array}$
    5454                static_assert( sizeof( (*pa)[0] ) == 4 ); $\C{// first element}$
    5555                static_assert( sizeof(&((*pa)[0])) == 8 ); $\C{// pointer to first element}$
     
    5858
    5959        float fs@[]@ = {3.14, 1.77};
    60         char cs@[]@ = "hello";    // shorthand for 'h', 'e', 'l', 'l', 'o', '\0'
     60        char cs@[]@ = "hello";                                  // shorthand for { 'h', 'e', 'l', 'l', 'o', '\0' }
    6161        static_assert( sizeof(fs) == 2 * sizeof(float) );
    6262        static_assert( sizeof(cs) == 6 * sizeof(char) );  $\C{// 5 letters + 1 null terminator}$
  • doc/theses/mike_brooks_MMath/programs/bkgd-carray-decay.c

    ra3bd827 r520fa9e  
    3030        edit( "hello" );                        $\C{// Segmentation fault [decay here]}$
    3131
    32         void decay( float x[10] ) {
    33                 static_assert( sizeof(x) == sizeof(void *) );
     32        void decay( @float x[10]@ ) {
     33                static_assert(@sizeof(x) == sizeof(void *)@ );
    3434        }
    3535        static_assert( sizeof(ar) == 10 * sizeof(float) );
    3636        decay( ar );
    3737
    38         void no_decay( float (*px)[10] ) {
    39                 static_assert( sizeof(*px) == 10 * sizeof(float) );
     38        void no_decay( @float (*px)[10]@ ) {
     39                static_assert(@sizeof(*px) == 10 * sizeof(float)@);
    4040        }
    4141        static_assert( sizeof(*pa) == 10 * sizeof(float) );
  • doc/theses/mike_brooks_MMath/programs/bkgd-carray-mdim.c

    ra3bd827 r520fa9e  
    1515int main() {
    1616        float ar[3][10];
    17         static_assert(sizeof(float) == 4);                      $\C{// floats (atomic elements) are 4 bytes}$
    18         static_assert(sizeof(void*) == 8);                      $\C{// pointers are 8 bytes}$
     17        static_assert( sizeof(float) == 4 );    $\C{// floats (atomic elements) are 4 bytes}$
     18        static_assert( sizeof(void*) == 8 );    $\C{// pointers are 8 bytes}$
    1919
    20         static_assert(sizeof(ar) == 120);                       $\C{// the array, float[3][10]}$
    21         static_assert(sizeof(ar[0]) == 40);                     $\C{// its first element, float[10]}$
    22         static_assert(sizeof(ar[0][0]) == 4);           $\C{// its first grand element, float}$
     20        static_assert( sizeof(ar) == 120 );             $\C{// the array, float[3][10]}$
     21        static_assert( sizeof(ar[0]) == 40 );   $\C{// its first element, float[10]}$
     22        static_assert( sizeof(ar[0][0]) == 4 ); $\C{// its first grand element, float}$
    2323
    24         static_assert(sizeof(&(ar)) == 8);                      $\C{// pointer to the array, float(*)[3][10]}$
    25         static_assert(sizeof(&(ar[0])) == 8);           $\C{// pointer to its first element, float(*)[10]}$
    26         static_assert(sizeof(&(ar[0][0])) == 8);        $\C{// pointer to its first grand-element, float*}$
     24        static_assert( sizeof(&(ar)) == 8 );    $\C{// pointer to the array, float(*)[3][10]}$
     25        static_assert( sizeof(&(ar[0])) == 8 ); $\C{// pointer to its first element, float(*)[10]}$
     26        static_assert( sizeof(&(ar[0][0])) == 8 );      $\C{// pointer to its first grand-element, float*}$
    2727
    2828        float (*pa)[3][10] = &(ar);
     
    3030        float *pa00 = &(ar[0][0]);
    3131
    32         static_assert((void*)&ar == (void*)&(ar[0] ));
    33         static_assert((void*)&ar == (void*)&(ar[0][0]));
     32        static_assert( (void*)&ar == (void*)&(ar[0] ) );
     33        static_assert( (void*)&ar == (void*)&(ar[0][0]) );
    3434
    3535        assert( (void *) pa == (void *) pa0 );
Note: See TracChangeset for help on using the changeset viewer.