Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.cfa

    r3d2852a r852a2f06  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr 22 10:50:46 2020
    13 // Update Count     : 933
     12// Last Modified On : Wed Mar 11 14:35:35 2020
     13// Update Count     : 860
    1414//
    1515
     
    2929#include <complex.h>                                                                    // creal, cimag
    3030} // extern "C"
    31 
    32 #include <bitmanip.hfa>                                                                 // fms
    3331
    3432
     
    461459\
    462460                if ( f.base == 'b' || f.base == 'B' ) {                 /* bespoke binary format */ \
    463                         int bits = high1( f.val );                                      /* position of most significant bit */ \
    464                         if ( bits == 0 ) bits = 1;                                      /* 0 value => force one bit to print */ \
     461                        int bits;                                                                                                       \
     462                        if ( f.val == (T){0} ) bits = 1;                        /* force at least one bit to print */ \
     463                        else bits = sizeof(long long int) * 8 - __builtin_clzll( f.val ); /* position of most significant bit */ \
     464                        bits = bits > sizeof(f.val) * 8 ? sizeof(f.val) * 8 : bits; \
    465465                        int spaces = f.wd - bits;                                       /* can be negative */ \
    466466                        if ( ! f.flags.nobsdp ) { spaces -= 2; }        /* base prefix takes space */ \
     
    565565                                fmt2.flags.pad0 = fmt2.flags.nobsdp = true;     \
    566566                                if ( f.base == 'b' | f.base == 'B' ) { \
    567                                         if ( fmt.flags.pc && fmt.pc > 64 ) fmt.pc -= 64; \
    568                                         if ( fmt.flags.left ) { \
    569                                                 fmt2.wd = fmt.wd; \
    570                                                 if ( fmt2.wd <= 64 ) { \
    571                                                         fmt2.wd = 64; \
    572                                                 } else { \
    573                                                         if ( fmt.pc > 0 ) { \
    574                                                                 fmt2.wd -= fmt.pc; \
    575                                                         } else { \
    576                                                                 fmt2.wd = fmt.wd - high1( msig ); \
    577                                                         } /* if */ \
    578                                                         if ( ! fmt.flags.nobsdp ) fmt2.wd -= 2; \
    579                                                         if ( fmt2.wd < 0 ) fmt2.wd = 0; \
    580                                                         fmt2.flags.left = true; \
    581                                                         fmt.wd = 0; \
    582                                                 } /* if */ \
    583                                                 printf( "left %d %d %x\n", f.wd, f.pc, f.all ); \
    584                                                 printf( "left %d %d %x\n", fmt.wd, fmt.pc, fmt.all ); \
    585                                         } else { \
    586                                                 fmt2.wd = 64; \
    587                                                 if ( fmt.wd > 64 ) fmt.wd -= 64; \
    588                                                 printf( "left %d %d %x\n", f.wd, f.pc, f.all ); \
    589                                                 printf( "left %d %d %x\n", fmt.wd, fmt.pc, fmt.all ); \
    590                                         } /* if */ \
    591                                         fmt2.pc = 64; fmt2.flags.pc = true;     \
    592                                         printf( "left %d %d %x\n", fmt2.wd, fmt2.pc, fmt2.all ); \
     567                                        if ( f.wd > 64 ) fmt.wd = f.wd - 64; \
     568                                        if ( f.flags.pc && f.pc > 64 ) fmt.pc = f.pc - 64; \
     569                                        fmt2.wd = 64; \
    593570                                        (ostype &)(os | fmt | "" | fmt2); \
    594571                                } else if ( f.base == 'o' ) { \
    595                                         if ( fmt.flags.pc && fmt.pc > 21 ) fmt.pc -= 21; \
    596                                         if ( fmt.flags.left ) { \
    597                                                 fmt.flags.left = false; \
    598                                                 fmt.wd = 1; \
    599                                                 fmt.val = (unsigned long long int)fmt.val >> 2; \
    600                                                 fmt2.wd = 1; \
    601                                                 fmt2.val = ((msig & 0x3) << 1) + 1; \
    602                                                 (ostype &)(os | fmt | "" | fmt2); \
    603                                                 sepOff( os ); \
    604                                                 fmt2.flags.left = true; \
    605                                                 fmt2.wd = f.wd - ( ceiling( high1( fmt.val ), 3 ) + 1 ); \
    606                                                 fmt2.flags.pc = true; fmt2.pc = 21; \
    607                                                 if ( ! fmt.flags.nobsdp ) { fmt2.wd -= 1; } \
    608                                                 fmt2.val = lsig & 0x7fffffffffffffff; \
    609                                                 (ostype &)(os | fmt2); \
     572                                        fmt.val = (unsigned long long int)fmt.val >> 2; \
     573                                        if ( f.wd > 21 ) fmt.wd = f.wd - 21; \
     574                                        if ( f.flags.pc && f.pc > 21 ) fmt.pc = f.pc - 21; \
     575                                        fmt2.wd = 1; \
     576                                        fmt2.val = ((msig & 0x3) << 1) + 1; \
     577                                        (ostype &)(os | fmt | "" | fmt2); \
     578                                        sepOff( os ); \
     579                                        fmt2.wd = 21; \
     580                                        fmt2.val = lsig & 0x7fffffffffffffff; \
     581                                        (ostype &)(os | fmt2); \
     582                                } else { \
     583                                        if ( f.flags.left ) { \
     584                                                if ( f.wd > 16 ) fmt2.wd = f.wd - 16; \
     585                                                fmt.wd = 16; \
    610586                                        } else { \
    611                                                 fmt.val = (unsigned long long int)fmt.val >> 2; \
    612                                                 if ( fmt.wd > 21 ) fmt.wd -= 21; \
    613                                                 if ( ! fmt.flags.nobsdp ) { if ( fmt.pc < fmt.wd ) fmt.wd -= 1; else fmt.pc -= 1; } \
    614                                                 fmt2.wd = 1; \
    615                                                 fmt2.val = ((msig & 0x3) << 1) + 1; \
    616                                                 (ostype &)(os | fmt | "" | fmt2); \
    617                                                 sepOff( os ); \
    618                                                 fmt2.wd = 21; \
    619                                                 fmt2.val = lsig & 0x7fffffffffffffff; \
    620                                                 (ostype &)(os | fmt2); \
     587                                                if ( f.wd > 16 ) fmt.wd = f.wd - 16; \
     588                                                if ( f.flags.pc && f.pc > 16 ) fmt.pc = f.pc - 16; \
     589                                                fmt2.wd = 16; \
    621590                                        } /* if */ \
    622                                 } else { \
    623                                         if ( fmt.flags.pc && fmt.pc > 16 ) fmt.pc -= 16; \
    624                                         if ( fmt.flags.left ) { \
    625                                                 fmt2.wd = fmt.wd; \
    626                                                 if ( fmt2.wd <= 16 ) { \
    627                                                         fmt2.wd = 16; \
    628                                                 } else { \
    629                                                         if ( fmt.pc > 0 ) { \
    630                                                                 fmt2.wd -= fmt.pc; \
    631                                                         } else { \
    632                                                                 fmt2.wd = fmt.wd - ceiling2( high1( msig ), 4 ) / 4; \
    633                                                         } /* if */ \
    634                                                         if ( ! fmt.flags.nobsdp ) fmt2.wd -= 2; \
    635                                                         if ( fmt2.wd < 0 ) fmt2.wd = 0; \
    636                                                         fmt2.flags.left = true; \
    637                                                         fmt.wd = 0; \
    638                                                 } /* if */ \
    639                                         } else { \
    640                                                 fmt2.wd = 16; \
    641                                                 if ( fmt.wd > 16 ) fmt.wd -= 16; \
    642                                         } /* if */ \
    643                                         fmt2.pc = 16; fmt2.flags.pc = true; \
    644591                                        (ostype &)(os | fmt | "" | fmt2); \
    645592                                } /* if */ \
Note: See TracChangeset for help on using the changeset viewer.